redis.clients.jedis.JedisCommands Java Examples
The following examples show how to use
redis.clients.jedis.JedisCommands.
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: BlackListController.java From feiqu-opensource with Apache License 2.0 | 6 votes |
@PostMapping("/manage/add") @ResponseBody public BaseResult add(String ip){ BaseResult result = new BaseResult(); try { if(!Validator.isIpv4(ip)){ result.setResult(ResultEnum.FAIL); result.setMessage("IP格式不正确!"); return result; } JedisCommands commands = JedisProviderFactory.getJedisCommands(null); commands.sadd(CommonConstant.FQ_BLACK_LIST_REDIS_KEY,ip); } catch (Exception e) { logger.error("",e); }finally { JedisProviderFactory.getJedisProvider(null).release();; } return result; }
Example #2
Source File: CommonUtils.java From feiqu-opensource with Apache License 2.0 | 6 votes |
public static void addActiveNum(Integer userId,double score){ int month = DateUtil.thisMonth()+1; String key = CommonConstant.FQ_ACTIVE_USER_SORT+month; try { JedisCommands commands = JedisProviderFactory.getJedisCommands(null); Double scoreStore = commands.zscore(key,userId.toString()); if(scoreStore == null){ scoreStore = score; }else { scoreStore += score; } commands.zadd(key,scoreStore,userId.toString()); commands.expire(key,180*24*60*60); } catch (Exception e) { logger.error(e); }finally { JedisProviderFactory.getJedisProvider(null).release(); } }
Example #3
Source File: DefaultCacheProvider.java From azeroth with Apache License 2.0 | 6 votes |
@Override public void clearGroup(final String groupName, final boolean containPkCache) { String cacheGroupKey = groupName + CacheHandler.GROUPKEY_SUFFIX; JedisCommands commands = JedisProviderFactory.getJedisCommands(null); try { Set<String> keys = commands.zrange(cacheGroupKey, 0, -1); //删除实际的缓存 if (keys != null && keys.size() > 0) { RedisBatchCommand.removeObjects(keys.toArray(new String[0])); } commands.del(cacheGroupKey); //删除按ID缓存的 if (containPkCache) { keys = JedisProviderFactory.getMultiKeyCommands(null).keys(groupName + ".id:*"); if (keys != null && keys.size() > 0) { RedisBatchCommand.removeObjects(keys.toArray(new String[0])); } } } finally { JedisProviderFactory.getJedisProvider(null).release(); } }
Example #4
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long expireAt(final String key, final long unixTime){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.expireAt(key, unixTime); } }); }
Example #5
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long sadd(final String key, final String... members) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.sadd(key, members); } }); }
Example #6
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long scard(final String key) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.scard(key); } }); }
Example #7
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public boolean hset(final String key, final String field, final String value) { return exec(new RedisCallback<Boolean>() { @Override public Boolean doCallback(JedisCommands jedis) { return jedis.hset(key, field, value) > 0; } }); }
Example #8
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Map<String, String> hgetAll(final String key) { return exec(new RedisCallback<Map<String,String>>() { @Override public Map<String, String> doCallback(JedisCommands jedis) { return jedis.hgetAll(key); } }); }
Example #9
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public List<String> hmget(final String key, final String... fields) { return exec(new RedisCallback<List<String>>() { @Override public List<String> doCallback(JedisCommands jedis) { return jedis.hmget(key, fields); } }); }
Example #10
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long hincrBy(final String key,final String field, final Long increment) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.hincrBy(key, field, increment); } }); }
Example #11
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public String hmset(final String key, final Map<String, String> fieldValues) { return exec(new RedisCallback<String>() { @Override public String doCallback(JedisCommands jedis) { return jedis.hmset(key, fieldValues); } }); }
Example #12
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
public Set<String> zrevrangeByScore(final String key, final double max, final double min){ return exec(new RedisCallback<Set<String>>() { @Override public Set<String> doCallback(JedisCommands jedis) { return jedis.zrevrangeByScore(key, max, min); } }); }
Example #13
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long decr(final String key) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.decr(key); } }); }
Example #14
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long incrby(final String key, final Long increment) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.incrBy(key, increment); } }); }
Example #15
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long incr(final String key) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.incr(key); } }); }
Example #16
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long ttl(final String key){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.ttl(key); } }); }
Example #17
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long persist(final String key){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.persist(key); } }); }
Example #18
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long decrby(final String key, final Long decrement) { return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.decrBy(key, decrement); } }); }
Example #19
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long expire(final String key, final Integer seconds){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.expire(key, seconds); } }); }
Example #20
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
public Long zrank(final String key, final String member){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.zrank(key, member); } }); }
Example #21
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public String set(final String key, final int seconds, final String value) { return exec(new RedisCallback<String>() { @Override public String doCallback(JedisCommands jedis) { return jedis.setex(key, seconds, value); } }); }
Example #22
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public String get(final String key) { return exec(new RedisCallback<String>() { @Override public String doCallback(JedisCommands jedis) { return jedis.get(key); } }); }
Example #23
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
public Set<String> zrangeByScore(final String key, final double min, final double max, final int offset, final int count){ return exec(new RedisCallback<Set<String>>() { @Override public Set<String> doCallback(JedisCommands jedis) { return jedis.zrangeByScore(key, min, max, offset, count); } }); }
Example #24
Source File: SRandMember.java From solr-redis with Apache License 2.0 | 5 votes |
@Override public Map<String, Float> execute(final JedisCommands client, final SolrParams params) { final String key = ParamUtil.assertGetStringByName(params, "key"); final int count = ParamUtil.tryGetIntByName(params, "count", 1); log.debug("Fetching SRANDMEMBER from Redis for key: {} ({})", key, count); // Workaround for https://github.com/xetorthio/jedis/issues/665 return client instanceof Jedis ? ResultUtil.stringIteratorToMap(((Jedis) client).srandmember(key, count)) : null; }
Example #25
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
@Override public Long zadd(final String key, final Double score, final String member){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.zadd(key, score, member); } }); }
Example #26
Source File: LIndex.java From solr-redis with Apache License 2.0 | 5 votes |
@Override public Map<String, Float> execute(final JedisCommands client, final SolrParams params) { final String key = ParamUtil.assertGetStringByName(params, "key"); final int index = ParamUtil.tryGetIntByName(params, "index", 0); log.debug("Fetching LINDEX from Redis for key: {} ({})", key, index); return ResultUtil.stringIteratorToMap(Collections.singletonList(client.lindex(key, index))); }
Example #27
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
public Set<Tuple> zrevrangeWithScores(final String key, final long start, final long end){ return exec(new RedisCallback<Set<Tuple>>() { @Override public Set<Tuple> doCallback(JedisCommands jedis) { return jedis.zrevrangeWithScores(key, start, end); } }); }
Example #28
Source File: HMGet.java From solr-redis with Apache License 2.0 | 5 votes |
@Override public Map<String, Float> execute(final JedisCommands client, final SolrParams params) { final String key = ParamUtil.assertGetStringByName(params, "key"); final String[] fields = ParamUtil.getStringByPrefix(params, "field"); log.debug("Fetching HMGET from Redis for key: {} ({})", key, fields); return ResultUtil.stringIteratorToMap(client.hmget(key, fields)); }
Example #29
Source File: ZRangeByScore.java From solr-redis with Apache License 2.0 | 5 votes |
@Override public Map<String, Float> execute(final JedisCommands client, final SolrParams params) { final String key = ParamUtil.assertGetStringByName(params, "key"); final String min = ParamUtil.tryGetStringByName(params, "min", "-inf"); final String max = ParamUtil.tryGetStringByName(params, "max", "+inf"); final boolean withScores = ParamUtil.tryGetBooleanByName(params, "with_scores", true); log.debug("Fetching ZRANGEBYSCORE from Redis for key: {} ({}, {})", key, min, max); if (withScores) { return ResultUtil.tupleIteratorToMap(client.zrangeByScoreWithScores(key, min, max)); } else { return ResultUtil.stringIteratorToMap(client.zrangeByScore(key, min, max)); } }
Example #30
Source File: AbstractRedisOperation.java From easyooo-framework with Apache License 2.0 | 5 votes |
public Long zcount(final String key, final double min, final double max){ return exec(new RedisCallback<Long>() { @Override public Long doCallback(JedisCommands jedis) { return jedis.zcount(key, min, max); } }); }