Example usage for org.springframework.data.redis.support.collections RedisList getKey

List of usage examples for org.springframework.data.redis.support.collections RedisList getKey

Introduction

In this page you can find the example usage for org.springframework.data.redis.support.collections RedisList getKey.

Prototype

K getKey();

Source Link

Document

Returns the key associated with this entity.

Usage

From source file:com.greenline.guahao.biz.manager.cache.hrs.DictCacheManager.java

/**
 * //from www. j a v  a2s. c o m
 * 
 * @param list
 */
public void setDicts(String dictId, final List<DictDO> list) {

    if (StringUtils.isEmpty(dictId) || list == null || list.isEmpty()) {
        return;
    }

    final RedisList<String> redislist = dictList(dictId);
    redislist.clear();
    redislist.getOperations().execute(new SessionCallback<Object>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public Object execute(RedisOperations operations) throws DataAccessException {
            operations.watch(redislist.getKey());
            operations.multi();
            for (DictDO obj : list) {
                redislist.add(jackjson.writeString(obj));
            }
            operations.exec();
            return null;
        }
    });

    setExpire(redislist);
}

From source file:com.greenline.guahao.biz.manager.cache.hrs.ShiftCaseCacheManager.java

/**
 * ?//from   w w  w  .  jav a  2 s. c  om
 * 
 * @param list
 */
public void setShiftCases(ShiftQuery query, final List<ShiftCaseDO> list) {
    if (query == null) {
        return;
    }

    if (list == null || list.isEmpty()) {
        String key = getIsCachedKey(queryKey(query));
        // 
        String isCached = template.opsForValue().get(key);
        if (StringUtils.isEmpty(isCached)) {
            setExpire(key, "true");
        }
        return;
    }
    // add to list
    final RedisList<String> redislist = shiftQueryList(query);
    redislist.clear();
    redislist.getOperations().execute(new SessionCallback<Object>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public Object execute(RedisOperations operations) throws DataAccessException {
            operations.watch(redislist.getKey());
            operations.multi();
            for (ShiftCaseDO obj : list) {
                redislist.add(jackjson.writeString(obj));
            }
            operations.exec();
            return null;
        }
    });
    // 
    boolean expire = redislist.expire(this.getExpireTime(), TimeUnit.SECONDS);
    if (!expire) {
        // ??key
        template.delete(queryKey(query));
    }
}

From source file:com.greenline.guahao.biz.manager.cache.hrs.HospitalCacheManager.java

/**
 * /*from w w  w  .  j  a va  2s  .c  o  m*/
 * 
 * @param list
 */
public void setHospLevels(final List<HospitalLevelDO> list) {
    if (list == null || list.isEmpty()) {
        return;
    }

    final RedisList<String> leveList = hospitallevels();
    leveList.clear();
    leveList.getOperations().execute(new SessionCallback<Object>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public Object execute(RedisOperations operations) throws DataAccessException {
            operations.watch(leveList.getKey());
            operations.multi();
            for (HospitalLevelDO obj : list) {
                leveList.add(jackjson.writeString(obj));
            }
            operations.exec();
            return null;
        }
    });
    // 
    setExpire(leveList);
}

From source file:com.greenline.guahao.biz.manager.cache.hrs.HospitalCacheManager.java

/**
 * ?/*from  w w  w .  j ava  2  s. co  m*/
 * 
 * @param hospitalId
 * @param list
 */
public void setClinicTypes(String hospitalId, final List<ClinicTypeDO> list) {
    if (StringUtils.isEmpty(hospitalId) || list == null || list.isEmpty()) {
        return;
    }
    final RedisList<String> clinicTypes = clinicTypes(hospitalId);
    clinicTypes.clear();
    clinicTypes.getOperations().execute(new SessionCallback<Object>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public Object execute(RedisOperations operations) throws DataAccessException {
            operations.watch(clinicTypes.getKey());
            operations.multi();
            for (ClinicTypeDO obj : list) {
                clinicTypes.add(obj.getId());
            }
            operations.exec();
            return null;
        }
    });

    for (ClinicTypeDO obj : list) {
        setClinicType(obj.getId(), obj);
    }
    setExpire(clinicTypes);
}

From source file:com.greenline.guahao.biz.manager.cache.hrs.DepartmentCacheManager.java

/**
 * //from w  ww . j ava2s.  com
 * 
 * @param hospitalId
 * @param list
 */
public void setHospitalDepts(String hospitalId, final List<HospitalDepartmentDO> list) {
    if (hospitalId == null || list == null || list.isEmpty()) {
        return;
    }
    // 
    final RedisList<String> hDepts = hospitalDepts(hospitalId);
    // 
    hDepts.clear();
    // 
    hDepts.getOperations().execute(new SessionCallback<Object>() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public Object execute(RedisOperations operations) throws DataAccessException {
            operations.watch(hDepts.getKey());
            operations.multi();
            for (HospitalDepartmentDO obj : list) {
                hDepts.add(obj.getId());
            }
            operations.exec();
            return null;
        }
    });
    setExpire(hDepts);
    // ?
    for (HospitalDepartmentDO obj : list) {
        setHospitalDept(obj.getId(), obj);
    }
}