Java Code Examples for org.springframework.data.redis.core.HashOperations#putAll()

The following examples show how to use org.springframework.data.redis.core.HashOperations#putAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecruitService.java    From microservice-recruit with Apache License 2.0 5 votes vote down vote up
private void cacheRecruit(List<RecruitEntity> recruitList) {
    if (!recruitList.isEmpty()) {
        HashOperations<String, String, String> redisHash = redis.opsForHash();
        Map<String, String> redisMap = recruitList
                .stream()
                .collect(Collectors.toMap(r -> String.valueOf(r.getId()), JSONObject::toJSONString));
        redisHash.putAll(Constant.RECRUIT_REDIS_PREFIX, redisMap);
        // 缓存七天
        redis.expire(Constant.RECRUIT_REDIS_PREFIX, 7, TimeUnit.DAYS);
    }
}
 
Example 2
Source File: RecruitService.java    From microservice-recruit with Apache License 2.0 5 votes vote down vote up
private void cacheCompany(List<CompanyEntity> companyList) {
    if (!companyList.isEmpty()) {
        HashOperations<String, String, String> redisHash = redis.opsForHash();
        Map<String, String> redisMap = companyList
                .stream()
                .collect(Collectors.toMap(c -> String.valueOf(c.getId()), JSONObject::toJSONString));
        redisHash.putAll(Constant.COMPANY_REDIS_PREFIX, redisMap);
        // 缓存七天
        redis.expire(Constant.COMPANY_REDIS_PREFIX, 7, TimeUnit.DAYS);
    }
}
 
Example 3
Source File: RecruitService.java    From microservice-recruit with Apache License 2.0 5 votes vote down vote up
private void cacheRecruit(List<RecruitEntity> recruitList) {
    if (!recruitList.isEmpty()) {
        HashOperations<String, String, String> redisHash = redis.opsForHash();
        Map<String, String> redisMap = recruitList
                .stream()
                .collect(Collectors.toMap(r -> String.valueOf(r.getId()), JSONObject::toJSONString));
        redisHash.putAll(Constant.RECRUIT_REDIS_PREFIX, redisMap);
        // 缓存七天
        redis.expire(Constant.RECRUIT_REDIS_PREFIX, 7, TimeUnit.DAYS);
    }
}
 
Example 4
Source File: RecruitService.java    From microservice-recruit with Apache License 2.0 5 votes vote down vote up
private void cacheCompany(List<CompanyEntity> companyList) {
    if (!companyList.isEmpty()) {
        HashOperations<String, String, String> redisHash = redis.opsForHash();
        Map<String, String> redisMap = companyList
                .stream()
                .collect(Collectors.toMap(c -> String.valueOf(c.getId()), JSONObject::toJSONString));
        redisHash.putAll(Constant.COMPANY_REDIS_PREFIX, redisMap);
        // 缓存七天
        redis.expire(Constant.COMPANY_REDIS_PREFIX, 7, TimeUnit.DAYS);
    }
}
 
Example 5
Source File: RedisServiceImpl.java    From SpringBoot-Dubbo-Docker-Jenkins with Apache License 2.0 5 votes vote down vote up
@Override
public <K,HK,HV> boolean setMap(K key, Map<HK, HV> map, Long expireTime) {
    HashOperations<K, HK, HV> operations = redisTemplate.opsForHash();
    operations.putAll(key, map);

    if (expireTime != null) {
        redisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
    }
    return false;
}
 
Example 6
Source File: RedisServiceImpl.java    From SpringBoot-Base-System with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 添加map
 * 
 * @time 下午10:10:22
 * 
 * @version V1.0
 * @param key
 * @param map
 * @return
 * @throws Exception
 */
public boolean putMap(String key, Map<Integer, List<String>> map) throws Exception {

	try {
		HashOperations<Object, Integer, List<String>> hashOps = redisTemplate.opsForHash();
		hashOps.putAll(key, map);
	} catch (Exception e) {
		log.error("缓存map失败key错误信息:{}", e.getMessage());
		throw new Exception("缓存map失败key[" + key + ",error[" + e.getMessage() + "]", e);
	}
	return true;
}
 
Example 7
Source File: AbsRedisDao.java    From jeesupport with MIT License 5 votes vote down vote up
@Override
public void insertMap ( int _idx, Map< ID, T > _map, Class< T > _cls ) {
    try{
        database( _idx );
        HashOperations< String, ID, T > hash = tpl.opsForHash();
        String sn = _cls.getSimpleName();
        hash.putAll( sn, _map );
    }catch ( Exception e ){
        log.error( "insertMap 发生错误:IDX=[" + _idx + "]" + e.toString(), e );
        throw e;
    }
}
 
Example 8
Source File: AbsRedisDao.java    From jeesupport with MIT License 5 votes vote down vote up
@Override
public void updateMap ( int _idx, Map< String, T > _map, Class< T > _cls ) {
    try{
        database( _idx );
        HashOperations< String, String, T > hash = tpl.opsForHash();
        String sn = _cls.getClass().getSimpleName();
        hash.putAll( sn, _map );
    }catch ( Exception e ){
        log.error( "update 发生错误:IDX=[" + _idx + "]" + e.toString(), e );
        throw e;
    }
}
 
Example 9
Source File: RedisSupport.java    From mykit-delay with Apache License 2.0 4 votes vote down vote up
public void hashPutAll(String key, Map<String, String> map) {
    HashOperations<String, String, String> hashOperations = template.opsForHash();
    hashOperations.putAll(key, map);
}
 
Example 10
Source File: RedisSupport.java    From sdmq with Apache License 2.0 4 votes vote down vote up
public void hashPutAll(String key, Map<String, String> map) {
    HashOperations<String, String, String> hashOperations = template.opsForHash();
    hashOperations.putAll(key, map);
}
 
Example 11
Source File: RedisHashServiceImpl.java    From paascloud-master with Apache License 2.0 4 votes vote down vote up
@Override
public void setValueByFields(String key, Map<String, Object> map) {
	HashOperations<String, String, Object> hash = rt.opsForHash();
	hash.putAll(key, map);
	log.info("setValueByFields - 同时将多个 field-value (域-值)对设置到哈希表 key 中. [ok] key={}, map={}", key, map);
}
 
Example 12
Source File: CacheServiceProvider.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
@Override
public void putAllHash(final String key, final Map<? extends Object, ? extends Object> keyValue) {
	final HashOperations<String, Object, Object> operation = redisTemplate.opsForHash();
	operation.putAll(getKey(key), keyValue);
}