org.springframework.data.redis.core.SetOperations Java Examples
The following examples show how to use
org.springframework.data.redis.core.SetOperations.
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: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 6 votes |
/** * 缓存set * * @param k key * @param v value * @param time time * @return boolean */ @Override public boolean cacheSet(String k, Set<String> v, long time) { String key = KEY_PREFIX_SET + k; try { SetOperations<String, String> setOps = redisTemplate.opsForSet(); setOps.add(key, v.toArray(new String[v.size()])); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Throwable t) { LOGGER.error("缓存[" + key + "]失败, value[" + v + "]", t); } return false; }
Example #2
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 6 votes |
/** * 缓存set操作 * * @param k key * @param v value * @param time time * @return boolean */ @Override public boolean cacheSet(String k, String v, long time) { String key = KEY_PREFIX_SET + k; try { SetOperations<String, String> valueOps = redisTemplate.opsForSet(); valueOps.add(key, v); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } return true; } catch (Throwable t) { LOGGER.error("缓存[" + key + "]失败, value[" + v + "]", t); } return false; }
Example #3
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
public void setSet(String k, T value, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> valueOps = redisTemplate.opsForSet(); valueOps.add(key, value); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #4
Source File: RedisSetServiceImpl.java From paascloud-master with Apache License 2.0 | 5 votes |
@Override public Long remove(String key, String... value) { SetOperations<String, String> setOps = rt.opsForSet(); Long result = setOps.remove(key, (Object) value); log.info("remove - 根据key移除元素, key={}, value={}, result={}", key, value, result); return result; }
Example #5
Source File: AbstractFeatureStrategyTest.java From WTFDYUM with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void _init() { principalService = mock(PrincipalService.class); followersService = mock(FollowersService.class); twitterService = mock(TwitterService.class); featureRedisTemplate = mock(RedisTemplate.class); featureSetOperations = mock(SetOperations.class); }
Example #6
Source File: CommonRedisDaoImpl.java From SpringBootUnity with MIT License | 5 votes |
/** * 获取缓存set数据 * * @param k key * @return set */ @Override public Set<String> getSet(String k) { try { SetOperations<String, String> setOps = redisTemplate.opsForSet(); return setOps.members(KEY_PREFIX_SET + k); } catch (Throwable t) { LOGGER.error("获取set缓存失败key[" + KEY_PREFIX_SET + k + ", Codeor[" + t + "]"); } return null; }
Example #7
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setSet(String k, T value, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> valueOps = redisTemplate.opsForSet(); valueOps.add(key, value); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #8
Source File: RedisSetServiceImpl.java From paascloud-master with Apache License 2.0 | 5 votes |
@Override public Long add(String key, String... value) { SetOperations<String, String> setOps = rt.opsForSet(); Long result = setOps.add(key, value); log.info("add - 向key里面添加元素, key={}, value={}, result={}", key, value, result); return result; }
Example #9
Source File: RedisSetServiceImpl.java From paascloud-master with Apache License 2.0 | 5 votes |
@Override public Set<String> getAllValue(String key) { Set<String> result; SetOperations<String, String> setOps = rt.opsForSet(); result = setOps.members(key); log.info("getAllValue - 根据key获取元素. [OK] key={}, value={}", key, result); return result; }
Example #10
Source File: DataRedisContextInitializer.java From summerframework with Apache License 2.0 | 5 votes |
private void createProxyHandlers(RedisTemplate redisTemplate) { createProxyHandler(redisTemplate, ValueOperations.class, "valueOps"); createProxyHandler(redisTemplate, ListOperations.class, "listOps"); createProxyHandler(redisTemplate, SetOperations.class, "setOps"); createProxyHandler(redisTemplate, ZSetOperations.class, "zSetOps"); createProxyHandler(redisTemplate, GeoOperations.class, "geoOps"); createProxyHandler(redisTemplate, HyperLogLogOperations.class, "hllOps"); }
Example #11
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setSet(String k, Set<T> v, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); setOps.add(key, (T[]) v.toArray()); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #12
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setSet(String k, Set<T> v, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); setOps.add(key, (T[]) v.toArray()); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #13
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public Set<T> getSet(String k) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("getSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); return setOps.members(key); } catch (Throwable t) { logger.error("getSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #14
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public Set<T> getSet(String k) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("getSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); return setOps.members(key); } catch (Throwable t) { logger.error("getSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #15
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setSet(String k, Set<T> v, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); setOps.add(key, (T[]) v.toArray()); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #16
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public void setSet(String k, T value, long time) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("setSet key [{}]", key); try { SetOperations<String, T> valueOps = redisTemplate.opsForSet(); valueOps.add(key, value); if (time > 0) { redisTemplate.expire(key, time, TimeUnit.SECONDS); } } catch (Throwable t) { logger.error("setSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #17
Source File: RedisCacheUtils.java From sophia_scaffolding with Apache License 2.0 | 5 votes |
public Set<T> getSet(String k) { String key = GlobalsConstants.KEY_SET_PREFIX + k; logger.debug("getSet key [{}]", key); try { SetOperations<String, T> setOps = redisTemplate.opsForSet(); return setOps.members(key); } catch (Throwable t) { logger.error("getSet key [{}] exception!", key, t); throw new CommonException(t); } }
Example #18
Source File: MyRedisTemplate.java From redis-admin with Apache License 2.0 | 4 votes |
@Override public SetOperations<K, V> opsForSet() { int dbIndex = RedisApplication.redisConnectionDbIndex.get(); return new DefaultSetOperations<K, V>(this, dbIndex); }
Example #19
Source File: CacheServiceProvider.java From AsuraFramework with Apache License 2.0 | 4 votes |
@Override public Set<String> rangeSet(final String key) { final SetOperations<String, String> operation = redisTemplate.opsForSet(); final Set<String> value = operation.members(getKey(key)); return value; }
Example #20
Source File: CacheServiceProvider.java From AsuraFramework with Apache License 2.0 | 4 votes |
@Override public void pushSet(final String key, final String... values) { final SetOperations<String, String> operation = redisTemplate.opsForSet(); operation.add(getKey(key), values); }
Example #21
Source File: CacheServiceProvider.java From AsuraFramework with Apache License 2.0 | 4 votes |
@Override public String popSet(final String key) { final SetOperations<String, String> operation = redisTemplate.opsForSet(); final String value = operation.pop(getKey(key)); return value; }
Example #22
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 删除Set缓存 * @param key * @param t */ public void deleteSet(String key,T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); opsForSet.remove(key,t); }
Example #23
Source File: RedisConfig.java From sophia_scaffolding with Apache License 2.0 | 2 votes |
/** * 实例化 SetOperations 对象,可以使用 Set 操作 * * @param redisTemplate * @return */ @Bean public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForSet(); }
Example #24
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 判断Set是否存在value * @param key * @param t * @return */ public boolean setHasValue(String key, T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); return opsForSet.isMember(key, t); }
Example #25
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 设置Set缓存 * @param key * @param t */ public void cacheSet(String key,T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); opsForSet.add(key,t); }
Example #26
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 判断Set是否存在value * @param key * @param t * @return */ public boolean setHasValue(String key, T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); return opsForSet.isMember(key, t); }
Example #27
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 删除Set缓存 * @param key * @param t */ public void deleteSet(String key,T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); opsForSet.remove(key,t); }
Example #28
Source File: RedisService.java From JavaQuarkBBS with Apache License 2.0 | 2 votes |
/** * 设置Set缓存 * @param key * @param t */ public void cacheSet(String key,T t){ SetOperations<String,T> opsForSet = redisTemplate.opsForSet(); opsForSet.add(key,t); }
Example #29
Source File: RedisConfig.java From sophia_scaffolding with Apache License 2.0 | 2 votes |
/** * 实例化 SetOperations 对象,可以使用 Set 操作 * * @param redisTemplate * @return */ @Bean public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForSet(); }
Example #30
Source File: RedisConfig.java From sophia_scaffolding with Apache License 2.0 | 2 votes |
/** * 实例化 SetOperations 对象,可以使用 Set 操作 * * @param redisTemplate * @return */ @Bean public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { return redisTemplate.opsForSet(); }