Example usage for org.springframework.data.redis.connection StringRedisConnection set

List of usage examples for org.springframework.data.redis.connection StringRedisConnection set

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection StringRedisConnection set.

Prototype

@Nullable
Boolean set(String key, String value);

Source Link

Document

Set value for key .

Usage

From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java

@Test // DATAREDIS-431
public void dbIndexShouldBePropagatedCorrectly() {

    LettuceConnectionFactory factory = new LettuceConnectionFactory();
    factory.setClientResources(LettuceTestClientResources.getSharedClientResources());
    factory.setDatabase(2);//from  w  ww.j  ava 2 s . c o m
    factory.afterPropertiesSet();

    ConnectionFactoryTracker.add(factory);

    StringRedisConnection connectionToDbIndex2 = new DefaultStringRedisConnection(factory.getConnection());

    try {

        String key = "key-in-db-2";
        connectionToDbIndex2.set(key, "the wheel of time");

        assertThat(connection.get(key), nullValue());
        assertThat(connectionToDbIndex2.get(key), notNullValue());
    } finally {
        connectionToDbIndex2.close();
    }
}