use of io.lettuce.core.RedisClient in project yyl_example by Relucent.
the class LettuceExample method main.
public static void main(String[] args) {
RedisClient client = RedisClient.create(RedisURI.create("redis://localhost/"));
try (StatefulRedisConnection<String, String> conn = client.connect()) {
RedisCommands<String, String> command = conn.sync();
command.set("hello", "hello lettuce");
String value = command.get("hello");
System.out.println(value);
}
}
use of io.lettuce.core.RedisClient in project verify-hub by alphagov.
the class PolicyModule method getRedisSessionStore.
private RedisSessionStore getRedisSessionStore(RedisConfiguration config) {
RedisClient redisClient = RedisClient.create();
redisClient.setDefaultTimeout(config.getTimeout());
StatefulRedisMasterSlaveConnection<SessionId, State> redisConnection = MasterSlave.connect(redisClient, new SessionStoreRedisCodec(getRedisObjectMapper()), singletonList(config.getUri()));
RedisCommands<SessionId, State> redisCommands = redisConnection.sync();
return new RedisSessionStore(redisCommands, config.getRecordTTL());
}
use of io.lettuce.core.RedisClient in project verify-hub by alphagov.
the class SamlEngineModule method getIdExpirationCache.
private <T> IdExpirationCache<T> getIdExpirationCache(RedisConfiguration config, RedisCodec<T, DateTime> codec, int dbIndex) {
RedisClient redisClient = RedisClient.create();
redisClient.setDefaultTimeout(config.getTimeout());
RedisURI uri = config.getUri();
uri.setDatabase(dbIndex);
StatefulRedisMasterSlaveConnection<T, DateTime> redisConnection = MasterSlave.connect(redisClient, codec, singletonList(uri));
RedisCommands<T, DateTime> redisCommands = redisConnection.sync();
return new RedisIdExpirationCache<>(redisCommands, config.getRecordTTL());
}
use of io.lettuce.core.RedisClient in project jetcache by alibaba.
the class MultiLevelCacheMixTest method testWithLettuce.
@Test
public void testWithLettuce() {
l1Cache = CaffeineCacheBuilder.createCaffeineCacheBuilder().limit(10).expireAfterWrite(1000, TimeUnit.MILLISECONDS).keyConvertor(FastjsonKeyConvertor.INSTANCE).buildCache();
RedisClient client = RedisClient.create("redis://127.0.0.1");
l2Cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder().redisClient(client).keyConvertor(FastjsonKeyConvertor.INSTANCE).valueEncoder(JavaValueEncoder.INSTANCE).valueDecoder(JavaValueDecoder.INSTANCE).keyPrefix(new Random().nextInt() + "").expireAfterWrite(1000, TimeUnit.MILLISECONDS).buildCache();
cache = MultiLevelCacheBuilder.createMultiLevelCacheBuilder().addCache(l1Cache, l2Cache).buildCache();
testImpl();
}
use of io.lettuce.core.RedisClient in project jetcache by alibaba.
the class RedisLettuceCacheTest method testSimple.
@Test
public void testSimple() throws Exception {
RedisClient client = RedisClient.create("redis://127.0.0.1");
test(client, null);
}
Aggregations