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


Java Jedis.close方法代码示例

本文整理汇总了Java中redis.clients.jedis.Jedis.close方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.close方法的具体用法?Java Jedis.close怎么用?Java Jedis.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Jedis的用法示例。


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

示例1: sentinelMonitor

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void sentinelMonitor() {
  Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());

  try {
    // monitor new master
    String result = j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
    assertEquals("OK", result);

    // already monitored
    try {
      j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
      fail();
    } catch (JedisDataException e) {
      // pass
    }
  } finally {
    j.close();
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:21,代码来源:JedisSentinelTest.java

示例2: get

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public String get(String key) {
    Jedis jedis = null;
    String result = "";
    try {
        jedis = getJedis();
        if (jedis != null) {
            result = jedis.get(key);
        } else {
            logger.error("get opt connection null error!");
        }
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
            jedis = null;
        }
        logger.error("get value connect error:", e);
    } finally {
        returnJedisResource(jedis);
    }
    return result;
}
 
开发者ID:Zephery,项目名称:newblog,代码行数:22,代码来源:JedisUtil.java

示例3: exists

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 判断是否存在
 * @param existskey
 * @return
 */
public boolean exists(String existskey) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		return jds.exists(existskey.getBytes());
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
开发者ID:wjggwm,项目名称:webside,代码行数:21,代码来源:RedisManager.java

示例4: getAllService

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 获取所有服务列表
 */
public List<String> getAllService(){
	
	Jedis jedis = JedisTemplate.getJedis();
	List<String> services = null;
	try{
		services = jedis.lrange(onlineServices, 0, -1);
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		jedis.close();
	}
	
	return services;
	
}
 
开发者ID:smxc,项目名称:garlicts,代码行数:19,代码来源:SimpleServiceUrlRoute.java

示例5: test_jedis_proxy

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void test_jedis_proxy() {
    JedisPoolConfig config = new JedisPoolConfig();
    JaRedisPool pool = new JaRedisPool(config, "127.0.0.1", 6379);
    Jedis jedis = pool.getResource();
    jedis.set("hello", "world");
    Assert.assertEquals(jedis.get("hello"), "world");
    jedis.close();
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:10,代码来源:TestJedisProxyPool.java

示例6: flushConfig

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 清空配置.
 * @param name 应用opkind
 * @throws Exception Exception
 */
public void flushConfig(final String name) throws Exception{
    Jedis configJedis = o2iJedisPool.getResource();
    Set<String> configSet = configJedis.keys(name+"*");
    if(!CollectionUtils.isEmpty(configSet)){
        configJedis.del(configSet.toArray(new String[0]));
    }
    configJedis.close();
}
 
开发者ID:Zigin,项目名称:MonitorPlatform,代码行数:14,代码来源:O2iMonitorService.java

示例7: set

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public String set(String key, String value) {
	Jedis jedis = jedisPool.getResource();
	String result = jedis.set(key, value);
	jedis.close();
	return result;
}
 
开发者ID:mmdsyl,项目名称:BLOG-Microservice,代码行数:8,代码来源:JedisClientPool.java

示例8: hexists

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Boolean hexists(String key, String field) {
	Jedis jedis = jedisPool.getResource();
	Boolean result = jedis.hexists(key, field);
	jedis.close();
	return result;
}
 
开发者ID:Exrick,项目名称:xmall,代码行数:8,代码来源:JedisClientPool.java

示例9: get

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 获取String值
 * @param key
 * @return value
 */
public synchronized static String get(String key) {
	Jedis jedis = getJedis();
	if (null == jedis) {
		return null;
	}
	String value = jedis.get(key);
	jedis.close();
	return value;
}
 
开发者ID:javay,项目名称:zheng-lite,代码行数:15,代码来源:RedisUtil.java

示例10: sadd

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * sadd
 * @param key
 * @param value
 * @param seconds
 */
public synchronized static void sadd(String key, String value, int seconds) {
	try {
		Jedis jedis = RedisUtil.getJedis();
		jedis.sadd(key, value);
		jedis.expire(key, seconds);
		jedis.close();
	} catch (Exception e) {
		_log.error("sadd error : " + e);
	}
}
 
开发者ID:javay,项目名称:zheng-lite,代码行数:17,代码来源:RedisUtil.java

示例11: remove

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 删除值
 * @param key
 */
public synchronized static void remove(String key) {
	try {
		Jedis jedis = getJedis();
		jedis.del(key);
		jedis.close();
	} catch (Exception e) {
		LOGGER.error("Remove keyex error : " + e);
	}
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:14,代码来源:RedisUtil.java

示例12: returnResourceShouldResetState

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Test
public void returnResourceShouldResetState() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
      "foobared", 2);

  Jedis jedis = pool.getResource();
  Jedis jedis2 = null;

  try {
    jedis.set("hello", "jedis");
    Transaction t = jedis.multi();
    t.set("hello", "world");
    pool.returnResource(jedis);

    jedis2 = pool.getResource();

    assertTrue(jedis == jedis2);
    assertEquals("jedis", jedis2.get("hello"));
  } catch (JedisConnectionException e) {
    if (jedis2 != null) {
      pool.returnBrokenResource(jedis2);
      jedis2 = null;
    }
  } finally {
    if (jedis2 != null) jedis2.close();

    pool.destroy();
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:33,代码来源:JedisSentinelPoolTest.java

示例13: eval

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * Eval lua script command
 *
 * @param script
 * @param keys
 * @param args
 * @return
 */
public Object eval(String script, List<String> keys, List<String> args) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        return jedis.eval(script, keys, args);

    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
}
 
开发者ID:baidu,项目名称:dlock,代码行数:21,代码来源:JedisClient.java

示例14: getStringStringMap

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private Map<String, String> getStringStringMap(String index) {
    Jedis jedis = getJedis();

    MapStructure<String> mapStructure = RedisStrutureBuilder.ofMap(jedis, String.class).withNameSpace(nameSpace).build();
    Map<String, String> map = mapStructure.get(index);

    Map<String, String> result = new HashMap<>();
    result.putAll(map);
    if (jedis != null) {
        jedis.close();
    }

    return result;
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:15,代码来源:CacheManager.java

示例15: get

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static Object get(String key) {
    Object reval = null;
    Jedis jedis = null;
    try {
        jedis = pool.getResource();
        reval = jedis.get(key);
    } catch (Exception e) {
        LOG.info("Error, idle : " + pool.getNumIdle() + ", active : " + pool.getNumActive() + ", waiter : " + pool.getNumWaiters());
    } finally {
        if(jedis != null) jedis.close();
    }
    return reval;
}
 
开发者ID:JiuzhouSec,项目名称:nightwatch,代码行数:14,代码来源:RedisLookUp.java


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