本文整理了Java中org.springframework.data.redis.core.BoundHashOperations
类的一些代码示例,展示了BoundHashOperations
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BoundHashOperations
类的具体详情如下:
包路径:org.springframework.data.redis.core.BoundHashOperations
类名称:BoundHashOperations
[英]Hash operations bound to a certain key.
[中]绑定到某个键的哈希操作。
代码示例来源:origin: spring-projects/spring-data-redis
@Override
@Nullable
public V get(Object key) {
return hashOps.get(key);
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public V put(K key, V value) {
V oldV = get(key);
hashOps.put(key, value);
return oldV;
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
@Nullable
public V remove(Object key) {
V v = get(key);
hashOps.delete(key);
return v;
}
代码示例来源:origin: TyCoding/springboot-seckill
@Override
public Exposer exportSeckillUrl(long seckillId) {
Seckill seckill = (Seckill) redisTemplate.boundHashOps(key).get(seckillId);
if (seckill == null) {
//说明redis缓存中没有此key对应的value
//查询数据库,并将数据放入缓存中
seckill = seckillMapper.findById(seckillId);
if (seckill == null) {
//说明没有查询到
return new Exposer(false, seckillId);
} else {
//查询到了,存入redis缓存中。 key:秒杀表的ID值; value:秒杀表数据
redisTemplate.boundHashOps(key).put(seckill.getSeckillId(), seckill);
logger.info("RedisTemplate -> 从数据库中读取并放入缓存中");
}
} else {
logger.info("RedisTemplate -> 从缓存中读取");
}
Date startTime = seckill.getStartTime();
Date endTime = seckill.getEndTime();
//获取系统时间
Date nowTime = new Date();
if (nowTime.getTime() < startTime.getTime() || nowTime.getTime() > endTime.getTime()) {
return new Exposer(false, seckillId, nowTime.getTime(), startTime.getTime(), endTime.getTime());
}
//转换特定字符串的过程,不可逆的算法
String md5 = getMD5(seckillId);
return new Exposer(true, md5, seckillId);
}
代码示例来源:origin: yzgod/tw-sso
/** 记录用户登录后对应userId和SessionId的Map关系 */
private static void addToMap(User user) {
String uId = user.getId().toString();
String sId = getRequest().getSession().getId();
Boolean hasKey = ou.hasKey(uId);
if (hasKey) {
String sids = ou.get(uId);
ou.put(uId, sids + sId);
} else {
ou.put(uId, sId);
}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
Map<K, V> entries = hashOps.entries();
checkResult(entries);
return entries.entrySet();
}
代码示例来源:origin: dhis2/dhis2-core
summaryKeyToBeDeleted.forEach( d -> redisTemplate.boundHashOps( summaryKey ).delete( d ) );
redisTemplate.boundHashOps( summaryKey ).put( id.getUid(),
objectMapper.writeValueAsString( jobSummary ) );
Date now = new Date();
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public boolean containsKey(Object key) {
Boolean result = hashOps.hasKey(key);
checkResult(result);
return result;
}
代码示例来源:origin: TyCoding/springboot-seckill
@Override
public List<Seckill> findAll() {
List<Seckill> seckillList = redisTemplate.boundHashOps("seckill").values();
if (seckillList == null || seckillList.size() == 0){
//说明缓存中没有秒杀列表数据
//查询数据库中秒杀列表数据,并将列表数据循环放入redis缓存中
seckillList = seckillMapper.findAll();
for (Seckill seckill : seckillList){
//将秒杀列表数据依次放入redis缓存中,key:秒杀表的ID值;value:秒杀商品数据
redisTemplate.boundHashOps(key).put(seckill.getSeckillId(), seckill);
logger.info("findAll -> 从数据库中读取放入缓存中");
}
}else{
logger.info("findAll -> 从缓存中读取");
}
return seckillList;
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long increment(K key, long delta) {
return hashOps.increment(key, delta);
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Boolean expire(long timeout, TimeUnit unit) {
return hashOps.expire(timeout, unit);
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public void putAll(Map<? extends K, ? extends V> m) {
hashOps.putAll(m);
}
代码示例来源:origin: spring-projects/spring-session
this.redis.boundValueOps(sessionKey).append("");
this.redis.boundValueOps(sessionKey).persist();
this.redis.boundHashOps(getSessionKey(session.getId())).persist();
return;
.expire(fiveMinutesAfterExpires, TimeUnit.SECONDS);
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Set<K> keySet() {
return hashOps.keys();
}
代码示例来源:origin: chengzhx76/weixin-shop-spring-cloud
public Long increase(String key, String field) {
BoundHashOperations hashOps = redisTemplate.boundHashOps(key);
//redisTemplate.setKeySerializer(new StringRedisSerializer(StandardCharsets.UTF_8));
//redisTemplate.setValueSerializer(new StringRedisSerializer());
//redisTemplate.setHashKeySerializer(new StringRedisSerializer(StandardCharsets.UTF_8));
redisTemplate.setHashValueSerializer(new GenericToStringSerializer(Long.class));
if (exists(key, field)) {
return hashOps.increment(field, 1L);
} else {
hashOps.putIfAbsent(field, 1);
return 1L;
}
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-dataflow-admin-starter
@Override
public Page<StreamDefinition> findAll(Pageable pageable) {
List<StreamDefinition> results;
List<String> allKeys = new ArrayList<>(hashOperations.keys());
int total = allKeys.size();
if (total == 0) {
results = Collections.emptyList();
}
else {
Collections.sort(allKeys, comparatorFor(pageable.getSort().getOrderFor("name").getDirection()));
int start = pageable.getOffset();
int end = Math.min(pageable.getOffset() + pageable.getPageSize(), total);
List<String> pageKeys = allKeys.subList(start, end);
List<String> definitions = hashOperations.multiGet(pageKeys);
results = zipToStreamDefinitions(pageKeys, definitions);
}
return new PageImpl<>(results, pageable, total);
}
代码示例来源:origin: TyCoding/springboot-seckill
Seckill seckill = (Seckill) redisTemplate.boundHashOps(key).get(seckillId);
seckill.setStockCount(seckill.getSeckillId() - 1);
redisTemplate.boundHashOps(key).put(seckillId, seckill);
代码示例来源:origin: spring-projects/spring-session
/**
* Gets the session.
* @param id the session id
* @param allowExpired if true, will also include expired sessions that have not been
* deleted. If false, will ensure expired sessions are not returned.
* @return the Redis session
*/
private RedisSession getSession(String id, boolean allowExpired) {
Map<Object, Object> entries = getSessionBoundHashOperations(id).entries();
if (entries.isEmpty()) {
return null;
}
MapSession loaded = loadSession(id, entries);
if (!allowExpired && loaded.isExpired()) {
return null;
}
RedisSession result = new RedisSession(loaded);
result.originalLastAccessTime = loaded.getLastAccessedTime();
return result;
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-dataflow-admin-starter
@Override
public boolean exists(String s) {
return hashOperations.hasKey(s);
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long increment(Object key, long delta) {
return hashOps.increment((String) key, delta);
}
内容来源于网络,如有侵权,请联系作者删除!