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


Java AbstractRedisClient类代码示例

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


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

示例1: unwrap

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
@Override
public <T> T unwrap(Class<T> clazz) {
    Objects.requireNonNull(clazz);
    if (AbstractRedisClient.class.isAssignableFrom(clazz)) {
        return (T) client;
    } else if (RedisClusterCommands.class.isAssignableFrom(clazz)) {
        // RedisCommands extends RedisClusterCommands
        return (T) stringCommands;
    } else if (RedisClusterAsyncCommands.class.isAssignableFrom(clazz)) {
        // RedisAsyncCommands extends RedisClusterAsyncCommands
        return (T) stringAsyncCommands;
    } else if (RedisClusterReactiveCommands.class.isAssignableFrom(clazz)) {
        // RedisReactiveCommands extends RedisClusterReactiveCommands
        return (T) lettuceConnectionManager.reactiveCommands(client);
    }
    throw new IllegalArgumentException(clazz.getName());
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:18,代码来源:RedisLettuceCache.java

示例2: removeAndClose

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public void removeAndClose(AbstractRedisClient redisClient) {
    LettuceObjects lo = (LettuceObjects) map.remove(redisClient);
    if (lo == null) {
        return;
    }
    if (lo.commands != null && lo.commands instanceof RedisClusterCommands) {
        ((RedisClusterCommands) lo.commands).close();
    }
    if (lo.asyncCommands != null && lo.asyncCommands instanceof RedisClusterAsyncCommands) {
        ((RedisClusterAsyncCommands) lo.asyncCommands).close();
    }
    if (lo.reactiveCommands != null && lo.reactiveCommands instanceof RedisClusterReactiveCommands) {
        ((RedisClusterReactiveCommands) lo.reactiveCommands).close();
    }
    if (lo.connection != null) {
        lo.connection.close();
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:19,代码来源:LettuceConnectionManager.java

示例3: Lettuce4Factory

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public Lettuce4Factory(String key, Class<?> clazz) {
    this.clazz = clazz;
    if (AbstractRedisClient.class.isAssignableFrom(clazz)) {
        key += ".client";
    } else if (StatefulConnection.class.isAssignableFrom(clazz)) {
        key += ".connection";
    } else if (RedisClusterCommands.class.isAssignableFrom(clazz)) {
        // RedisCommands extends RedisClusterCommands
        key += ".commands";
    } else if (RedisClusterAsyncCommands.class.isAssignableFrom(clazz)) {
        // RedisAsyncCommands extends RedisClusterAsyncCommands
        key += ".asyncCommands";
    } else if (RedisClusterReactiveCommands.class.isAssignableFrom(clazz)) {
        // RedisReactiveCommands extends RedisClusterReactiveCommands
        key += ".reactiveCommands";
    } else {
        throw new IllegalArgumentException(clazz.getName());
    }
    this.key = key;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:21,代码来源:Lettuce4Factory.java

示例4: connection

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public StatefulConnection connection(AbstractRedisClient redisClient) {
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.connection == null) {
        if (redisClient instanceof RedisClient) {
            lo.connection = ((RedisClient) redisClient).connect(new JetCacheCodec());
        } else if (redisClient instanceof RedisClusterClient) {
            lo.connection = ((RedisClusterClient) redisClient).connect(new JetCacheCodec());
        } else {
            throw new CacheConfigException("type " + redisClient.getClass() + " is not supported");
        }
    }
    return lo.connection;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:14,代码来源:LettuceConnectionManager.java

示例5: commands

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public Object commands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.commands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.commands = ((StatefulRedisConnection) lo.connection).sync();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.commands = ((StatefulRedisClusterConnection) lo.connection).sync();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.commands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java

示例6: asyncCommands

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public Object asyncCommands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.asyncCommands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.asyncCommands = ((StatefulRedisConnection) lo.connection).async();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.asyncCommands = ((StatefulRedisClusterConnection) lo.connection).async();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.asyncCommands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java

示例7: reactiveCommands

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public Object reactiveCommands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.reactiveCommands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.reactiveCommands = ((StatefulRedisConnection) lo.connection).reactive();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.reactiveCommands = ((StatefulRedisClusterConnection) lo.connection).reactive();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.reactiveCommands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java

示例8: testUnwrap

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
private void testUnwrap(AbstractRedisClient client) {
    Assert.assertTrue(cache.unwrap(AbstractRedisClient.class) instanceof AbstractRedisClient);
    if (client instanceof RedisClient) {
        Assert.assertTrue(cache.unwrap(RedisClient.class) instanceof RedisClient);
        Assert.assertTrue(cache.unwrap(RedisCommands.class) instanceof RedisCommands);
        Assert.assertTrue(cache.unwrap(RedisAsyncCommands.class) instanceof RedisAsyncCommands);
        Assert.assertTrue(cache.unwrap(RedisReactiveCommands.class) instanceof RedisReactiveCommands);
    } else {
        Assert.assertTrue(cache.unwrap(RedisClusterClient.class) instanceof RedisClusterClient);
        Assert.assertTrue(cache.unwrap(RedisClusterCommands.class) instanceof RedisClusterCommands);
        Assert.assertTrue(cache.unwrap(RedisClusterAsyncCommands.class) instanceof RedisClusterAsyncCommands);
        Assert.assertTrue(cache.unwrap(RedisClusterReactiveCommands.class) instanceof RedisClusterReactiveCommands);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:RedisLettuceCacheTest.java

示例9: initCache

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
@Override
protected CacheBuilder initCache(ConfigTree ct, String cacheAreaWithPrefix) {
    Map<String, Object> map = ct.subTree("uri"/*there is no dot*/).getProperties();
    AbstractRedisClient client = null;
    if (map == null || map.size() == 0) {
        throw new CacheConfigException("uri is required");
    } else if (map.size() == 1) {
        String uri = (String) map.values().iterator().next();
        client = RedisClient.create(uri);
    } else {
        List<RedisURI> list = map.values().stream().map((k) -> RedisURI.create(URI.create(k.toString())))
                .collect(Collectors.toList());
        client = RedisClusterClient.create(list);
    }

    ExternalCacheBuilder externalCacheBuilder = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client);
    parseGeneralConfig(externalCacheBuilder, ct);

    // eg: "remote.default.client"
    autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".client", client);
    LettuceConnectionManager m = LettuceConnectionManager.defaultManager();
    autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".connection", m.connection(client));
    autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".commands", m.commands(client));
    autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".asyncCommands", m.asyncCommands(client));
    autoConfigureBeans.getCustomContainer().put(cacheAreaWithPrefix + ".reactiveCommands", m.reactiveCommands(client));
    return externalCacheBuilder;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:29,代码来源:RedisLettuce4AutoConfiguration.java

示例10: getRedisClient

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public AbstractRedisClient getRedisClient() {
    return redisClient;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:4,代码来源:RedisLettuceCacheConfig.java

示例11: setRedisClient

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public void setRedisClient(AbstractRedisClient redisClient) {
    this.redisClient = redisClient;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:4,代码来源:RedisLettuceCacheConfig.java

示例12: setRedisClient

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
public void setRedisClient(AbstractRedisClient redisClient) {
    getConfig().setRedisClient(redisClient);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:4,代码来源:RedisLettuceCacheBuilder.java

示例13: getLettuceObjectsFromMap

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
private LettuceObjects getLettuceObjectsFromMap(AbstractRedisClient redisClient) {
    return (LettuceObjects) map.computeIfAbsent(redisClient, key -> new LettuceObjects());
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:4,代码来源:LettuceConnectionManager.java

示例14: test

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
private void test(AbstractRedisClient client) throws Exception {
    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .keyConvertor(FastjsonKeyConvertor.INSTANCE)
            .valueEncoder(JavaValueEncoder.INSTANCE)
            .valueDecoder(JavaValueDecoder.INSTANCE)
            .keyPrefix(new Random().nextInt() + "")
            .expireAfterWrite(500, TimeUnit.MILLISECONDS)
            .buildCache();
    baseTest();
    expireAfterWriteTest(cache.config().getExpireAfterWriteInMillis());
    fastjsonKeyCoverterTest();
    testUnwrap(client);

    LoadingCacheTest.loadingCacheTest(RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .keyConvertor(FastjsonKeyConvertor.INSTANCE)
            .valueEncoder(JavaValueEncoder.INSTANCE)
            .valueDecoder(JavaValueDecoder.INSTANCE)
            .keyPrefix(new Random().nextInt() + ""), 50);

    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .keyConvertor(null)
            .valueEncoder(KryoValueEncoder.INSTANCE)
            .valueDecoder(KryoValueDecoder.INSTANCE)
            .keyPrefix(new Random().nextInt() + "")
            .buildCache();
    nullKeyConvertorTest();

    int thread = 10;
    int time = 3000;
    cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder()
            .redisClient(client)
            .keyConvertor(FastjsonKeyConvertor.INSTANCE)
            .valueEncoder(KryoValueEncoder.INSTANCE)
            .valueDecoder(KryoValueDecoder.INSTANCE)
            .keyPrefix(new Random().nextInt() + "")
            .buildCache();
    concurrentTest(thread, 500, time);
    LettuceConnectionManager.defaultManager().removeAndClose(client);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:43,代码来源:RedisLettuceCacheTest.java

示例15: syncHandler

import com.lambdaworks.redis.AbstractRedisClient; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T syncHandler(Object asyncApi, Class<?>... interfaces) {
    FutureSyncInvocationHandler<K, V> h = new FutureSyncInvocationHandler<K, V>(this, asyncApi);
    return (T) Proxy.newProxyInstance(AbstractRedisClient.class.getClassLoader(), interfaces, h);
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:6,代码来源:DisqueConnectionImpl.java


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