org.springframework.data.redis.connection.RedisConnection.pExpire()方法的使用及代码示例

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

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

RedisConnection.pExpire介绍

暂无

代码示例

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

@Override
public Boolean pExpire(byte[] key, long millis) {
  return convertAndReturn(delegate.pExpire(key, millis), identityConverter);
}

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

@Override
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
  Assert.notNull(name, "Name must not be null!");
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return execute(name, connection -> {
    if (isLockingCacheWriter()) {
      doLock(name, connection);
    }
    try {
      if (connection.setNX(key, value)) {
        if (shouldExpireWithin(ttl)) {
          connection.pExpire(key, ttl.toMillis());
        }
        return null;
      }
      return connection.get(key);
    } finally {
      if (isLockingCacheWriter()) {
        doUnlock(name, connection);
      }
    }
  });
}

代码示例来源: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: 1991wangliang/tx-lcn

@Override
public Boolean pExpire(byte[] key, long millis) {
  return redisConnection.pExpire(key, millis);
}

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

@Override
public Boolean pExpire(byte[] key, long millis) {
  return convertAndReturn(delegate.pExpire(key, millis), identityConverter);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Boolean pExpire(byte[] key, long millis) {
  return convertAndReturn(delegate.pExpire(key, millis), identityConverter);
}

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

@Override
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
  Assert.notNull(name, "Name must not be null!");
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return execute(name, connection -> {
    if (isLockingCacheWriter()) {
      doLock(name, connection);
    }
    try {
      if (connection.setNX(key, value)) {
        if (shouldExpireWithin(ttl)) {
          connection.pExpire(key, ttl.toMillis());
        }
        return null;
      }
      return connection.get(key);
    } finally {
      if (isLockingCacheWriter()) {
        doUnlock(name, connection);
      }
    }
  });
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
  Assert.notNull(name, "Name must not be null!");
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return execute(name, connection -> {
    if (isLockingCacheWriter()) {
      doLock(name, connection);
    }
    try {
      if (connection.setNX(key, value)) {
        if (shouldExpireWithin(ttl)) {
          connection.pExpire(key, ttl.toMillis());
        }
        return null;
      }
      return connection.get(key);
    } finally {
      if (isLockingCacheWriter()) {
        doUnlock(name, connection);
      }
    }
  });
}

代码示例来源:origin: org.springframework.data/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: apache/servicemix-bundles

@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);
}

相关文章

微信公众号

最新文章

更多

RedisConnection类方法