Example #1
0
  @Test
  public void testGet() {

    ValueOperations<String, String> valueops = stringRedisTemplate.opsForValue();
    String name = valueops.get("name");
    System.err.println("get name = " + name);
  }
Example #2
0
  @Test
  public void testSet() {

    ValueOperations<String, String> valueops = stringRedisTemplate.opsForValue();
    valueops.set("name", "liuboTemplate");
    System.err.println("set name");
  }
  public String add(User user) {

    String sid = new SessionToolUtil().generateSessionId();

    ValueOperations<String, User> valueops = redisTemplate.opsForValue();
    valueops.set(sid, user);

    return sid;
  }
 public Object get(Object key) {
   return operations.get(key);
 }
 public void set(Object key, Object value, Long expire) {
   operations.set(key, value, expire, TimeUnit.SECONDS);
 }
 public void set(Object key, Object value) {
   operations.set(key, value);
 }
 public Object get(final CodisCacheKey cacheKey) {
   return operations.get(cacheKey.ganerateKey());
 }
 public void set(final CodisCacheKey cacheKey, final Object value) {
   String key = cacheKey.ganerateKey();
   this.addIndex(cacheKey.ganerateGroup(), key);
   operations.set(key, value, cacheKey.getExpiration(), TimeUnit.SECONDS);
 }
Example #9
0
 private void setUserCache(String appId, String sessionToken, BaasUser user) {
   ValueOperations<String, String> ops = redisTemplate.opsForValue();
   ops.set(
       "App_" + appId + USER_CLASS_NAME + "_" + sessionToken, jsonUtil.writeValueAsString(user));
 }
Example #10
0
 private BaasUser getUserCache(String appId, String sessionToken) {
   ValueOperations<String, String> ops = redisTemplate.opsForValue();
   String userStr = ops.get("App_" + appId + USER_CLASS_NAME + "_" + sessionToken);
   return jsonUtil.readValue(userStr, BaasUser.class);
 }
  public User get(String id) {

    ValueOperations<String, User> valueops = redisTemplate.opsForValue();
    User user = valueops.get(id);
    return user;
  }
Example #12
0
 // String数据类型  将value追加到已存在的某key的value值末尾
 public void append(String key, String value) {
   valueOps = redisTemplate.opsForValue();
   valueOps.append(key, value);
 }
Example #13
0
 // String数据类型 存储一对键值并设置有效时间 支持value为非String类型
 public void set(String key, Serializable value, long timeout, TimeUnit unit) {
   valueOps = redisTemplate.opsForValue();
   valueOps.set(key, value, timeout, unit);
 }
Example #14
0
 // String数据类型 存储一对键值 支持value为非String类型
 public void set(String key, Serializable value) {
   valueOps = redisTemplate.opsForValue();
   valueOps.set(key, value);
 }
Example #15
0
 /**
  * String数据类型 读取键为key的值 支持value非String类型
  *
  * @param key
  * @return value值
  */
 public Serializable get(String key) {
   valueOps = redisTemplate.opsForValue();
   return valueOps.get(key);
 }
Example #16
0
 /**
  * /** String数据类型 如果value存储的是Integer类型值则增加
  *
  * @param key
  * @param value
  * @return 递增后的新增
  * @throws InvalidDataAccessApiUsageException value不是Integer类型时报错
  */
 public long increment(String key, long value) throws InvalidDataAccessApiUsageException {
   valueOps = redisTemplate.opsForValue();
   return valueOps.increment(key, value);
 }