本文整理了Java中org.springframework.data.redis.core.BoundHashOperations.putIfAbsent()
方法的一些代码示例,展示了BoundHashOperations.putIfAbsent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BoundHashOperations.putIfAbsent()
方法的具体详情如下:
包路径:org.springframework.data.redis.core.BoundHashOperations
类名称:BoundHashOperations
方法名:putIfAbsent
[英]Set the value of a hash key only if key does not exist.
[中]仅当哈希键不存在时才设置哈希键的值。
代码示例来源:origin: spring-projects/spring-data-redis
@Override
@Nullable
public V putIfAbsent(K key, V value) {
return (hashOps.putIfAbsent(key, value) ? null : get(key));
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Object putIfAbsent(Object key, Object value) {
return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key));
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
@Nullable
public V putIfAbsent(K key, V value) {
return (hashOps.putIfAbsent(key, value) ? null : get(key));
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Object putIfAbsent(Object key, Object value) {
return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
@Nullable
public V putIfAbsent(K key, V value) {
return (hashOps.putIfAbsent(key, value) ? null : get(key));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Object putIfAbsent(Object key, Object value) {
return (hashOps.putIfAbsent((String) key, (String) value) ? null : get(key));
}
代码示例来源: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;
}
}
内容来源于网络,如有侵权,请联系作者删除!