//操作 Map
@Override
public void setMapObject(String token, Object object,String mapName,Long minutes) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
map.put(token, object,minutes, TimeUnit.MINUTES);
}
@Override
public Object getMapObject(String key, String mapName) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
return map.get(key);
}
@Override
public boolean updateExpire(String mapName, String key, long ttl, TimeUnit ttlUnit) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
return map.updateEntryExpiration(key, ttl, ttlUnit, 0, ttlUnit);
}
//操作 Map
@Override
public void delMapObject(String mapName, String key) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
map.remove(key);
}
@Override
public void delMapObjects(String mapName, List<String> keys) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
keys.stream().forEach(key -> {
map.remove(key);
});
}
@Override
public void setMapObject(String token, Object object, String mapName, long ttl,TimeUnit unit) {
RMapCache<String, Object> map = redissonClient.getMapCache(mapName);
map.put(token, object,ttl, unit);
}
//操作 String
@Override
public void setBucket(String key,String value,Long minutes) {
RBucket<Object> bucket = redissonClient.getBucket(key);
bucket.set(value,minutes,TimeUnit.MINUTES);
}
@Override
public String getBucket(String key) {
RBucket<String> bucket = redissonClient.getBucket(key);
return bucket.get();
}
@Override
public void delBucket(String key) {
RBucket<Object> bucket = redissonClient.getBucket(key);
bucket.delete();
}
//操作List
@Override
public void setList(String key, List<String> brandCodes,Long minutes) {
RList<String> list = redissonClient.getList(key);
brandCodes.forEach( s -> {
list.add(s);
});
list.expire(minutes,TimeUnit.MINUTES);
}
@Override
public List<String> getList(String key) {
RList<String> list = redissonClient.getList(key);
return list.readAll();
}
@Override
public void delList(String key) {
RList<String> list = redissonClient.getList(key);
list.remove(key);
}
redis map嵌套 redisson map
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java map循环中remove
java map循环中remove
迭代 Java 迭代器