org.springframework.data.redis.core.RedisTemplate.rawKey()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中org.springframework.data.redis.core.RedisTemplate.rawKey方法的一些代码示例,展示了RedisTemplate.rawKey的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisTemplate.rawKey方法的具体详情如下:
包路径:org.springframework.data.redis.core.RedisTemplate
类名称:RedisTemplate
方法名:rawKey

RedisTemplate.rawKey介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-redis

private byte[][] rawKeys(Collection<K> keys) {
  final byte[][] rawKeys = new byte[keys.size()][];
  int i = 0;
  for (K key : keys) {
    rawKeys[i++] = rawKey(key);
  }
  return rawKeys;
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean renameIfAbsent(K oldKey, K newKey) {
  byte[] rawOldKey = rawKey(oldKey);
  byte[] rawNewKey = rawKey(newKey);
  return execute(connection -> connection.renameNX(rawOldKey, rawNewKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public void rename(K oldKey, K newKey) {
  byte[] rawOldKey = rawKey(oldKey);
  byte[] rawNewKey = rawKey(newKey);
  execute(connection -> {
    connection.rename(rawOldKey, rawNewKey);
    return null;
  }, true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean unlink(K key) {
  byte[] rawKey = rawKey(key);
  Long result = execute(connection -> connection.unlink(rawKey), true);
  return result != null && result.intValue() == 1;
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean delete(K key) {
  byte[] rawKey = rawKey(key);
  Long result = execute(connection -> connection.del(rawKey), true);
  return result != null && result.intValue() == 1;
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public DataType type(K key) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.type(rawKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean hasKey(K key) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.exists(rawKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long getExpire(K key) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.ttl(rawKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean persist(K key) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.persist(rawKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean move(K key, final int dbIndex) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.move(rawKey, dbIndex), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean expireAt(K key, final Date date) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> {
    try {
      return connection.pExpireAt(rawKey, date.getTime());
    } catch (Exception e) {
      return connection.expireAt(rawKey, date.getTime() / 1000);
    }
  }, true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long sort(SortQuery<K> query, K storeKey) {
  byte[] rawStoreKey = rawKey(storeKey);
  byte[] rawKey = rawKey(query.getKey());
  SortParameters params = QueryUtils.convertQuery(query, stringSerializer);
  return execute(connection -> connection.sort(rawKey, params, rawStoreKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public void watch(K key) {
  byte[] rawKey = rawKey(key);
  execute(connection -> {
    connection.watch(rawKey);
    return null;
  }, true);
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Executes the Redis dump command and returns the results. Redis uses a non-standard serialization mechanism and
 * includes checksum information, thus the raw bytes are returned as opposed to deserializing with valueSerializer.
 * Use the return value of dump as the value argument to restore
 *
 * @param key The key to dump
 * @return results The results of the dump operation
 */
@Override
public byte[] dump(K key) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> connection.dump(rawKey), true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
@SuppressWarnings("unchecked")
public Set<K> keys(K pattern) {
  byte[] rawKey = rawKey(pattern);
  Set<byte[]> rawKeys = execute(connection -> connection.keys(rawKey), true);
  return keySerializer != null ? SerializationUtils.deserialize(rawKeys, keySerializer) : (Set<K>) rawKeys;
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long getExpire(K key, final TimeUnit timeUnit) {
  byte[] rawKey = rawKey(key);
  return execute(connection -> {
    try {
      return connection.pTtl(rawKey, timeUnit);
    } catch (Exception e) {
      // Driver may not support pTtl or we may be running on Redis 2.4
      return connection.ttl(rawKey, timeUnit);
    }
  }, true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public <T> List<T> sort(SortQuery<K> query, @Nullable RedisSerializer<T> resultSerializer) {
  byte[] rawKey = rawKey(query.getKey());
  SortParameters params = QueryUtils.convertQuery(query, stringSerializer);
  List<byte[]> vals = execute(connection -> connection.sort(rawKey, params), true);
  return SerializationUtils.deserialize(vals, resultSerializer);
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Executes the Redis restore command. The value passed in should be the exact serialized data returned from
 * {@link #dump(Object)}, since Redis uses a non-standard serialization mechanism.
 *
 * @param key The key to restore
 * @param value The value to restore, as returned by {@link #dump(Object)}
 * @param timeToLive An expiration for the restored key, or 0 for no expiration
 * @param unit The time unit for timeToLive
 * @param replace use {@literal true} to replace a potentially existing value instead of erroring.
 * @throws RedisSystemException if the key you are attempting to restore already exists and {@code replace} is set to
 *           {@literal false}.
 */
@Override
public void restore(K key, final byte[] value, long timeToLive, TimeUnit unit, boolean replace) {
  byte[] rawKey = rawKey(key);
  long rawTimeout = TimeoutUtils.toMillis(timeToLive, unit);
  execute(connection -> {
    connection.restore(rawKey, rawTimeout, value, replace);
    return null;
  }, true);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Boolean expire(K key, final long timeout, final TimeUnit unit) {
  byte[] rawKey = rawKey(key);
  long rawTimeout = TimeoutUtils.toMillis(timeout, unit);
  return execute(connection -> {
    try {
      return connection.pExpire(rawKey, rawTimeout);
    } catch (Exception e) {
      // Driver may not support pExpire or we may be running on Redis 2.4
      return connection.expire(rawKey, TimeoutUtils.toSeconds(timeout, unit));
    }
  }, true);
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public Long sort(SortQuery<K> query, K storeKey) {
  byte[] rawStoreKey = rawKey(storeKey);
  byte[] rawKey = rawKey(query.getKey());
  SortParameters params = QueryUtils.convertQuery(query, stringSerializer);
  return execute(connection -> connection.sort(rawKey, params, rawStoreKey), true);
}

相关文章

微信公众号

最新文章

更多