当前位置: 首页>>代码示例>>Java>>正文


Java RedisConnection类代码示例

本文整理汇总了Java中com.lambdaworks.redis.RedisConnection的典型用法代码示例。如果您正苦于以下问题:Java RedisConnection类的具体用法?Java RedisConnection怎么用?Java RedisConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RedisConnection类属于com.lambdaworks.redis包,在下文中一共展示了RedisConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clientKillExtended

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@Test
public void clientKillExtended() {

    RedisConnection<String, String> connection2 = client.connect().sync();
    connection2.clientSetname("killme");

    Pattern p = Pattern.compile("^.*addr=([^ ]+).*name=killme.*$", Pattern.MULTILINE | Pattern.DOTALL);
    String clients = redis.clientList();
    Matcher m = p.matcher(clients);

    assertThat(m.matches()).isTrue();
    String addr = m.group(1);
    assertThat(redis.clientKill(KillArgs.Builder.addr(addr).skipme())).isGreaterThan(0);

    assertThat(redis.clientKill(KillArgs.Builder.id(4234))).isEqualTo(0);
    assertThat(redis.clientKill(KillArgs.Builder.typeSlave().id(4234))).isEqualTo(0);
    assertThat(redis.clientKill(KillArgs.Builder.typeNormal().id(4234))).isEqualTo(0);
    assertThat(redis.clientKill(KillArgs.Builder.typePubsub().id(4234))).isEqualTo(0);

    connection2.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:22,代码来源:ServerCommandTest.java

示例2: testCreate

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {

    RedisConnection<String, String> connection = PoolingProxyFactory.create(client.pool());

    connection.set("a", "b");
    connection.close();

    try {
        connection.set("x", "y");
        fail("missing exception");
    } catch (RedisException e) {
        assertThat(e.getMessage()).isEqualTo("Connection pool is closed");

    }
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:17,代码来源:PoolingProxyFactoryTest.java

示例3: testLettuce

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@POST
@Path("testLettuce")
public void testLettuce(String jsonString) {

    RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
    RedisConnection<String, String> conn1 = redisClient.connect();

    conn1.set("foo", "bar");
    String value = conn1.get("foo");
    System.out.println(value);

    conn1.close();
    redisClient.shutdown();

    RedisClient client = RedisClient.create("redis://localhost:6379/0");
    RedisAsyncConnection<String, String> conn = client.connectAsync();
    conn.set("foo", "bar");

    conn.get("foo");

    conn.lpush("lll", "a");
    conn.lpush("lll", "b");
    conn.lpush("lll", "c");
    conn.lpop("lll");
    conn.lpop("lll");
    conn.lpop("lll");

    conn.hset("mmm", "abc", "123");
    conn.hset("mmm", "def", "456");
    conn.hgetall("mmm");

    conn.del("foo", "lll", "mmm");

    conn.close();
    client.shutdown();
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:37,代码来源:TestRestService.java

示例4: lettucetest

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@GET
@Path("lettucetest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String lettucetest() {

    System.out.println("TEST Lettuce sync ======================================================");
    RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
    RedisConnection<String, String> conn = redisClient.connect();

    conn.set("foo", "bar");

    conn.get("foo");

    conn.lpush("lll", "a");
    conn.lpush("lll", "b");
    conn.lpush("lll", "c");
    conn.lpop("lll");
    conn.lpop("lll");
    conn.lpop("lll");

    conn.hset("mmm", "abc", "123");
    conn.hset("mmm", "def", "456");
    conn.hgetall("mmm");

    conn.del("foo", "lll", "mmm");

    conn.close();
    redisClient.shutdown();
    return "lettucetest";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:31,代码来源:RedisService.java

示例5: testSync

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
private static void testSync() {

        System.out.println("TEST Lettuce sync ======================================================");
        RedisClient redisClient = RedisClient.create("redis://localhost:6379/0");
        RedisConnection<String, String> conn = redisClient.connect();

        System.out.println("Connected to Redis");

        conn.set("foo", "bar");
        String value = conn.get("foo");
        System.out.println(value);

        conn.close();
        redisClient.shutdown();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:16,代码来源:DoTestLettuceHookProxy.java

示例6: getRedisConnectionFactory

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
private Factory<RedisConnection> getRedisConnectionFactory() {
    final ConnectionConfig.RedisConnectionConfig connectionConfig = (ConnectionConfig.RedisConnectionConfig) cacheConfig.getConnectionConfig();

    if (connectionConfig != null) {
        if (connectionConfig.getPool() != null) {
            return new RedisConnectionPoolFactory(RedisClient.create(getRedisUri()), getRedisCodec());
        } else {
            return new RedisConnectionFactory(RedisClient.create(getRedisUri()), getRedisCodec());
        }
    }
    return null;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:13,代码来源:RedisCacheServiceBuilder.java

示例7: watch

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@Test
public void watch() {
    assertThat(redis.watch(key)).isEqualTo("OK");

    RedisConnection<String, String> redis2 = client.connect().sync();
    redis2.set(key, value + "X");
    redis2.close();

    redis.multi();
    redis.append(key, "foo");
    assertThat(redis.exec()).isEqualTo(list());

}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:14,代码来源:TransactionCommandTest.java

示例8: testCreateDefault

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@Test
public void testCreateDefault() throws Exception {

    RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
    RedisConnection<String, String> connection = PoolingProxyFactory.create(pool);

    connection.set("a", "b");
    connection.set("x", "y");

    pool.close();
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:12,代码来源:PoolingProxyFactoryTest.java

示例9: testCloseReturnsConnection

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
@Test
public void testCloseReturnsConnection() throws Exception {

    RedisConnectionPool<RedisCommands<String, String>> pool = client.pool();
    assertThat(pool.getNumActive()).isEqualTo(0);
    RedisConnection<String, String> connection = pool.allocateConnection();
    assertThat(pool.getNumActive()).isEqualTo(1);
    connection.close();
    assertThat(pool.getNumActive()).isEqualTo(0);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:11,代码来源:PoolingProxyFactoryTest.java

示例10: Builder

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public Builder(String id, TypeConfig.Cache cacheType, Factory<RedisConnection<K,V>> connFactory) {
    super(id, cacheType);
    this.connFactory = connFactory;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:5,代码来源:RedisCacheService.java

示例11: getConnFactory

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public Factory<RedisConnection<K, V>> getConnFactory() {
    return connFactory;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:4,代码来源:RedisCacheService.java

示例12: RedisAbstractCache

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public RedisAbstractCache(RedisConnection<K, V> redisConnection) {
    this(redisConnection, null);
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:4,代码来源:RedisAbstractCache.java

示例13: RedisStringsCache

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public RedisStringsCache(RedisConnection<K, V> redisConnection) {
    this(redisConnection, null);
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:4,代码来源:RedisStringsCache.java

示例14: RedisHashesCache

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public RedisHashesCache(RedisConnection<K, V> redisConnection, K key) {
    this(redisConnection, key, null);
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:4,代码来源:RedisHashesCache.java

示例15: create

import com.lambdaworks.redis.RedisConnection; //导入依赖的package包/类
public RedisConnection<K, V> create() {
    return redisClient.pool(codec, MAX_IDLE, MAX_ACTIVE).allocateConnection();
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:4,代码来源:RedisConnectionPoolFactory.java


注:本文中的com.lambdaworks.redis.RedisConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。