Java 类org.springframework.data.redis.core.SetOperations 实例源码

项目:SpringBootUnity    文件:CommonRedisDaoImpl.java   
/**
 * 缓存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;
}
项目:SpringBootUnity    文件:CommonRedisDaoImpl.java   
/**
 * 缓存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;
}
项目:diablo    文件:ServerDaoImpl.java   
@Override
public boolean serverOnline(String server) {

    SetOperations<String, String> ops = redis.opsForSet();
    ops.add(RedisKeys.CLUSTER_SERVERS_ONLINE, server);
    ops.remove(RedisKeys.CLUSTER_SERVERS_OFFLINE, server);

    return Boolean.TRUE;
}
项目:diablo    文件:ServerDaoImpl.java   
@Override
public boolean serverOffline(String server) {
    SetOperations<String, String> ops = redis.opsForSet();
    ops.remove(RedisKeys.CLUSTER_SERVERS_ONLINE, server);
    ops.add(RedisKeys.CLUSTER_SERVERS_OFFLINE, server);

    return Boolean.TRUE;
}
项目:SpringBootUnity    文件:CommonRedisDaoImpl.java   
/**
 * 获取缓存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;
}
项目:Camel    文件:RedisIdempotentRepositoryTest.java   
@Before
public void setUp() throws Exception {
    redisTemplate = mock(RedisTemplate.class);
    setOperations = mock(SetOperations.class);
    redisConnection = mock(RedisConnection.class);
    redisConnectionFactory = mock(RedisConnectionFactory.class);
    when(redisTemplate.opsForSet()).thenReturn(setOperations);
    when(redisTemplate.getConnectionFactory()).thenReturn(redisConnectionFactory);
    when(redisTemplate.getConnectionFactory().getConnection()).thenReturn(redisConnection);
    idempotentRepository = RedisIdempotentRepository.redisIdempotentRepository(redisTemplate, REPOSITORY);
}
项目:openyu-commons    文件:RedisBaoSupporter.java   
@Override
public SetOperations<K, V> opsForSet() {
    try {
        return redisTemplate.opsForSet();
    } catch (Exception ex) {
        throw new RedisBaoException(ex);
    }
}
项目:WTFDYUM    文件:AbstractFeatureStrategyTest.java   
@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);
}
项目:asura    文件:CacheServiceProvider.java   
@Override
public String popSet(final String key) {
    final SetOperations<String, String> operation = redisTemplate.opsForSet();
    final String value = operation.pop(getKey(key));
    return value;
}
项目:asura    文件:CacheServiceProvider.java   
@Override
public void pushSet(final String key, final String... values) {
    final SetOperations<String, String> operation = redisTemplate.opsForSet();
    operation.add(getKey(key), values);
}
项目:asura    文件:CacheServiceProvider.java   
@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;
}
项目:redis-admin    文件:MyRedisTemplate.java   
@Override
public SetOperations<K, V> opsForSet() {
    int dbIndex = RedisApplication.redisConnectionDbIndex.get();
    return new DefaultSetOperations<K, V>(this, dbIndex);
}
项目:springboot-quick-build    文件:RedisServiceImpl.java   
public SetOperations<String, String> setOps() {
    return redisTemplate.opsForSet();
}
项目:Camel    文件:RedisSetTest.java   
@Before
public void setUp() throws Exception {
    redisTemplate = mock(RedisTemplate.class);
    setOperations = mock(SetOperations.class);
    super.setUp();
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 设置Set缓存
 * @param key
 * @param t
 */
public void cacheSet(String key,T t){
    SetOperations<String,T> opsForSet = redisTemplate.opsForSet();
    opsForSet.add(key,t);
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 删除Set缓存
 * @param key
 * @param t
 */
public void deleteSet(String key,T t){
    SetOperations<String,T> opsForSet = redisTemplate.opsForSet();
    opsForSet.remove(key,t);
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 判断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);
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 设置Set缓存
 * @param key
 * @param t
 */
public void cacheSet(String key,T t){
    SetOperations<String,T> opsForSet = redisTemplate.opsForSet();
    opsForSet.add(key,t);
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 删除Set缓存
 * @param key
 * @param t
 */
public void deleteSet(String key,T t){
    SetOperations<String,T> opsForSet = redisTemplate.opsForSet();
    opsForSet.remove(key,t);
}
项目:JavaQuarkBBS    文件:RedisService.java   
/**
 * 判断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);
}
项目:phone    文件:RedisClientSupport.java   
public SetOperations<String, Object> opsForSet(){
        return redisTemplate.opsForSet();
    }
项目:openyu-commons    文件:RedisBao.java   
SetOperations<K, V> opsForSet();