当前位置: 首页>>代码示例>>Java>>正文


Java JedisCommands类代码示例

本文整理汇总了Java中redis.clients.jedis.JedisCommands的典型用法代码示例。如果您正苦于以下问题:Java JedisCommands类的具体用法?Java JedisCommands怎么用?Java JedisCommands使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JedisCommands类属于redis.clients.jedis包,在下文中一共展示了JedisCommands类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearGroup

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@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();
    }

}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:26,代码来源:DefaultCacheProvider.java

示例2: hkeys

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
public Set<String> hkeys(String key) {
	logger.trace("hkeys {}", key);
	JedisCommands client = dynoClient;
	Set<String> keys = new HashSet<>();
	int cursor = 0;
	do {
		ScanResult<Entry<String, String>> sr = client.hscan(key, "" + cursor);
		cursor = Integer.parseInt(sr.getStringCursor());
		List<Entry<String, String>> result = sr.getResult();
		for (Entry<String, String> e : result) {
			keys.add(e.getKey());
		}
	} while (cursor > 0);

	return keys;
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:17,代码来源:DynoProxy.java

示例3: smembers

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
public Set<String> smembers(String key) {
	logger.trace("smembers {}", key);
	JedisCommands client = dynoClient;
	Set<String> r = new HashSet<>();
	int cursor = 0;
	ScanParams sp = new ScanParams();
	sp.count(50);

	do {
		ScanResult<String> sr = client.sscan(key, "" + cursor, sp);
		cursor = Integer.parseInt(sr.getStringCursor());
		r.addAll(sr.getResult());

	} while (cursor > 0);

	return r;

}
 
开发者ID:Netflix,项目名称:conductor,代码行数:19,代码来源:DynoProxy.java

示例4: init

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Before
public void init() throws Exception {
	JedisCommands jedisMock = new JedisMock();
	dao = new DynoQueueDAO(jedisMock, jedisMock, new ShardSupplier() {

		@Override
		public Set<String> getQueueShards() {
			return Arrays.asList("a").stream().collect(Collectors.toSet());
		}

		@Override
		public String getCurrentShard() {
			return "a";
		}
	}, new TestConfiguration());
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:17,代码来源:DynoQueueDAOTest.java

示例5: clearGroup

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@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();
	}

}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:26,代码来源:DefaultCacheProvider.java

示例6: commitForCookie

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public WintCookie commitForCookie(final int expire) {
    redisClient.getRedisTemplate().executeNoResult(new RedisCommandNoResult() {
        @Override
        public void doInExec(JedisCommands commands) {
            String key = getRedisKey();
            if (commands.exists(key)) {
                commands.expire(key, expire);
            }
        }
    });

    WintCookie cookie = new WintCookie(config.getSessionIdName(), sessionId);
    String domain = config.getDomain();
    if (!StringUtil.isEmpty(domain)) {
        cookie.setDomain(domain);
    }
    cookie.setHttpOnly(true);
    // 设置为非持久化cookie
    //  cookie.setMaxAge(config.getExpire());
    cookie.setPath(config.getPath());
    return cookie;
}
 
开发者ID:pister,项目名称:wint,代码行数:24,代码来源:RedisSessionStore.java

示例7: exists

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public boolean exists(final String key) {
	JedisPool jedisPool = PoolThreadLocal.getPool();
	return new AbstractCommandCall() {
		@Override
		public <T> T exec(JedisCommands commands) {
			return (T) commands.exists(key);
		}
	}.call(jedisPool);
}
 
开发者ID:zh-cn-trio,项目名称:trioAop,代码行数:11,代码来源:CallRedisStringOperactionImpl.java

示例8: expireat

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public boolean expireat(final String key, final String val, final int cacheTime) {
	JedisPool jedisPool = PoolThreadLocal.getPool();
	return new AbstractCommandCall() {
		@Override
		public <T> T exec(JedisCommands commands) {
			commands.set(key, val);
			if (cacheTime > 0) {
				commands.expire(key, cacheTime);
			}
			return (T) Boolean.TRUE;
		}
	}.call(jedisPool);
}
 
开发者ID:zh-cn-trio,项目名称:trioAop,代码行数:15,代码来源:CallRedisStringOperactionImpl.java

示例9: get

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public String get(final String key) {
	JedisPool jedisPool = PoolThreadLocal.getPool();
	return new AbstractCommandCall() {
		@Override
		public <T> T exec(JedisCommands commands) {
			return (T) commands.get(key);
		}
	}.call(jedisPool);
}
 
开发者ID:zh-cn-trio,项目名称:trioAop,代码行数:11,代码来源:CallRedisStringOperactionImpl.java

示例10: del

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public boolean del(final String key) {
	JedisPool jedisPool = PoolThreadLocal.getPool();
	return new AbstractCommandCall() {
		@Override
		public <T> T exec(JedisCommands commands) {
			commands.del(key);
			return (T) Boolean.TRUE;
		}
	}.call(jedisPool);
}
 
开发者ID:zh-cn-trio,项目名称:trioAop,代码行数:12,代码来源:CallRedisStringOperactionImpl.java

示例11: interceptJedisCommands

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
private void interceptJedisCommands() {
  Class<JedisCommands> clazz = JedisCommands.class;
  Method[] methods = clazz.getDeclaredMethods();
  Set<String> methodNames = new HashSet<>();
  for (Method method : methods) {
    if (methodNames.contains(method.getName())) {
      continue;//over-loaded method
    }
    methodNames.add(method.getName());
    addRulesForOperation(method);
  }
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:13,代码来源:JedisRuleSet.java

示例12: putGroup

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public void putGroup(String cacheGroupKey, String key, long expireSeconds) {
    long score = calcScoreInRegionKeysSet(expireSeconds);
    JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
    try {
        commands.zadd(cacheGroupKey, score, key);
        commands.pexpire(cacheGroupKey, expireSeconds * 1000);
    } finally {
        JedisProviderFactory.getJedisProvider(null).release();
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:12,代码来源:DefaultCacheProvider.java

示例13: removeFromGroup

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public void removeFromGroup(String cacheGroupKey, String key) {
    JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
    try {
        commands.zrem(cacheGroupKey, key);
        //
        commands.del(key);
    } finally {
        JedisProviderFactory.getJedisProvider(null).release();
    }
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:12,代码来源:DefaultCacheProvider.java

示例14: clearExpiredGroupKeys

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
@Override
public void clearExpiredGroupKeys(String cacheGroup) {
    long maxScore = System.currentTimeMillis() / 1000 - this.baseScoreInRegionKeysSet;
    JedisCommands commands = JedisProviderFactory.getJedisCommands(null);
    try {
        commands.zremrangeByScore(cacheGroup, 0, maxScore);
    } finally {
        JedisProviderFactory.getJedisProvider(null).release();
    }
    logger.debug("clearExpiredGroupKeys runing:cacheName:{} , score range:0~{}", cacheGroup, maxScore);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:12,代码来源:DefaultCacheProvider.java

示例15: hgetAll

import redis.clients.jedis.JedisCommands; //导入依赖的package包/类
public Map<String, String> hgetAll(String key) {
	Map<String, String> m = new HashMap<>();
	JedisCommands dyno = dynoClient;
	int cursor = 0;
	do {
		ScanResult<Entry<String, String>> sr = dyno.hscan(key, "" + cursor);
		cursor = Integer.parseInt(sr.getStringCursor());
		for (Entry<String, String> r : sr.getResult()) {
			m.put(r.getKey(), r.getValue());
		}
	} while (cursor > 0);

	return m;
}
 
开发者ID:Netflix,项目名称:conductor,代码行数:15,代码来源:DynoProxy.java


注:本文中的redis.clients.jedis.JedisCommands类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。