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


Java Jedis.get方法代码示例

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


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

示例1: get

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public byte[] get(byte[] key){
	
	byte[] value = null;
	Jedis jedis = null;
	try{
		jedis = get();
		if (jedis == null)
			return null;
		value = jedis.get(key);
		pool.returnResource(jedis);
	}catch(Exception e){
		pool.returnBrokenResource(jedis);
	}
	
	return value;
}
 
开发者ID:x7-framework,项目名称:x7,代码行数:17,代码来源:JedisConnector_Cache3.java

示例2: get

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 获取缓存
 *
 * @param key 键
 * @return 值
 */
public static String get(String key) {
	String value = null;
	Jedis jedis = null;
	try {
		jedis = getResource();
		if (jedis.exists(key)) {
			value = jedis.get(key);
			value = StringUtils.isNotBlank(value) && !"nil".equalsIgnoreCase(value) ? value : null;
			logger.debug("get {} = {}", key, value);
		}
	} catch (Exception e) {
		logger.warn("get {} = {}", key, value, e);
	} finally {
		returnResource(jedis);
	}
	return value;
}
 
开发者ID:funtl,项目名称:framework,代码行数:24,代码来源:JedisUtils.java

示例3: loadSessionDataFromRedis

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public byte[] loadSessionDataFromRedis(String id) throws IOException {
	Jedis jedis = null;
	Boolean error = true;

	try {
		log.trace("Attempting to load session " + id + " from Redis");

		jedis = acquireConnection();
		byte[] data = jedis.get(id.getBytes());
		error = false;

		if (data == null) {
			log.trace("Session " + id + " not found in Redis");
		}

		return data;
	} finally {
		if (jedis != null) {
			returnConnection(jedis, error);
		}
	}
}
 
开发者ID:appNG,项目名称:appng-tomcat-session,代码行数:23,代码来源:RedisSessionManager.java

示例4: pullObject

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Object pullObject(String key) {

        log.trace("strar find cache with " + key);
        Jedis jedis = null;
        try {
            jedis = redisConnection.getJedis();
            jedis.select(dbIndex);
            byte[] result = jedis.get(key.getBytes());
            if (result == null) {
                log.trace("can not find caceh with " + key);
                return null;
            } else {
                log.trace("find cache success with " + key);
                return SerializeUtil.unserialize(result);
            }
        } catch (Exception e) {
            log.warn(e.getMessage(), e);
        } finally {
            if (jedis != null) {
                jedis.close();
            }
        }

        return null;
    }
 
开发者ID:gaochao2000,项目名称:redis_util,代码行数:26,代码来源:CacheServiceRedisImpl.java

示例5: getStringAndSuccess

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * 需要知道是否是成功获取的
 * 
 * @param key
 * @return
 */
public Object[] getStringAndSuccess(String key) {
	Jedis jedis = null;
	boolean success = true;
	String ret = "";
	try {
		jedis = jedisPool.getResource();
		if (jedis == null) {
			success = false;
			return null;
		}
		ret = jedis.get(key);
	} catch (Exception e) {
		success = false;
		returnBrokenResource(jedis, "getString", e);
	} finally {
		releaseReidsSource(success, jedis);
	}
	Object[] object = new Object[2];
	object[0] = success;
	object[1] = ret;
	return object;
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:29,代码来源:RedisService.java

示例6: foo

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private static void foo() {

        System.out.println("TEST Jedis ======================================================");
        Jedis jedis = new Jedis(ip, port);
        jedis.set("foo", "bar");

        jedis.get("foo");

        jedis.lpush("lll", "a");
        jedis.lpush("lll", "b");
        jedis.lpush("lll", "c");
        jedis.lpop("lll");
        jedis.lpop("lll");
        jedis.lpop("lll");

        jedis.hset("mmm", "abc", "123");
        jedis.hset("mmm", "def", "456");
        jedis.hgetAll("mmm");

        jedis.close();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:22,代码来源:DoTestJedisHookProxy.java

示例7: connectWithShardInfoAndCustomHostnameVerifier

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifier() {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:SSLJedisTest.java

示例8: connectWithShardInfoAndCustomSocketFactory

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * Tests opening an SSL/TLS connection to redis with a custom socket factory.
 */
@Test
public void connectWithShardInfoAndCustomSocketFactory() throws Exception {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = createTrustStoreSslSocketFactory();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:19,代码来源:SSLJedisTest.java

示例9: getCacheForObject

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public Object getCacheForObject(String key) {
    Jedis jedis = null;

    Object var3;
    try {
        jedis = pool.getResource();
        byte[] value = jedis.get(key.getBytes());
        var3 = SerializeUtil. unserialize(value);
    } catch (Exception var7) {
        throw new RuntimeException(var7);
    } finally {
        pool.returnResourceObject(jedis);
    }

    return var3;
}
 
开发者ID:bitstd,项目名称:bitstd,代码行数:17,代码来源:RedisCacheWithoutCluster.java

示例10: executeTask

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private void executeTask(TopicViewCountTask task) {

        Jedis jedis = redisManager.getJedis();
        String cacheValue = jedis.get(task.getKey());
        int count = cacheValue == null ? 0 : Integer.valueOf(cacheValue);

        if (count < 2) {

            jedis.incrBy(task.getKey(), task.getViews());
        } else {

            jedis.del(task.getKey());
            topicService.updateTopicViews(Long.valueOf(task.getTopicId()), count + task.getViews());
        }

        redisManager.retureRes(jedis);
    }
 
开发者ID:thundernet8,项目名称:Elune,代码行数:18,代码来源:TopicViewMQServiceImpl.java

示例11: jedispolltest

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@GET
@Path("jedispooltest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedispolltest() {

    System.out.println("TEST JedisPool ======================================================");
    JedisPoolConfig cfg = new JedisPoolConfig();
    cfg.setMaxTotal(5);
    cfg.setMaxIdle(1);
    cfg.setMaxWaitMillis(10000L);

    JedisPool jp = new JedisPool(cfg, "localhost", 6379);
    Jedis jedis = jp.getResource();

    jedis.set("foo", "bar");
    // jedis.close();
    jedis = jp.getResource();

    jedis.get("foo");
    // jedis.close();
    jedis = jp.getResource();

    jedis.lpush("lll", "a");
    jedis.lpush("lll", "b");
    jedis.lpush("lll", "c");
    jedis.lpop("lll");
    jedis.lpop("lll");
    jedis.lpop("lll");
    // jedis.close();
    jedis = jp.getResource();

    jedis.hset("mmm", "abc", "123");
    jedis.hset("mmm", "def", "456");
    jedis.hgetAll("mmm");

    jp.close();
    return "jedispooltest";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:RedisService.java

示例12: getWxToken

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
  * 获取微信Token
  * @return Token数据键值对
  */
 public Map<String, Object> getWxToken() {
     Jedis jedis = null;
     try{
         jedis = RedisConnectionFactory.getJedisInstance();
         String jsonString = jedis.get("token:" + this.appId);
         if(jsonString == null){
             return getNewWxToken();
         }else{
             Map<String, Object> tokenMap = JSON.parseObject(jsonString, new TypeReference<Map<String, Object>>(){});
             long nowTime = System.currentTimeMillis();
             if(nowTime < (Long.parseLong(tokenMap.get("time").toString())-5000)){
                 return tokenMap;
             }else{
                 return getNewWxToken();
             }
         }
     }catch (Exception e) {
         e.printStackTrace();
         logger.error("从Redis中取AccessToken时:" + e.toString());
         return null;
     }finally{
if(jedis != null){
	jedis.close();
}
     }
 }
 
开发者ID:rocye,项目名称:wx-idk,代码行数:31,代码来源:ThirdpartyAccessToken.java

示例13: 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

示例14: get

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

示例15: isKeyMatchAndAlive

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private boolean isKeyMatchAndAlive(Jedis jedis, String key, String value) {

        long ttl = jedis.ttl(key);
        if (ttl < 0) {
            return false;
        }

        String valueInRedis = jedis.get(key);
        if (valueInRedis == null || !valueInRedis.equals(value)) {
            return false;
        }

        return true;
    }
 
开发者ID:wushibin,项目名称:redislock,代码行数:15,代码来源:RedisLuaLockTest.java


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