其它特性

    允许给单个或所有 Redis 服务器发送 ping 请求:

    1. Collection<Node> allNodes = nodesGroup.getNodes();
    2. for (Node n : allNodes) {
    3. n.ping();
    4. }
    5. // or
    6. nodesGroup.pingAll();
    1. redisson.getBucket("foo").set("bar");
    2. "return redis.call('get', 'foo')", RScript.ReturnType.VALUE);
    3. // do the same using cache
    4. RScript s = redisson.getScript();
    5. String res = s.scriptLoad("return redis.call('get', 'foo')");
    6. // res == 282297a0228f48cd3fc6a55de6316f31422f5d17
    7. // call script by sha digest
    8. Future<Object> r1 = redisson.getScript().evalShaAsync(Mode.READ_ONLY,
    9. "282297a0228f48cd3fc6a55de6316f31422f5d17",
    10. RScript.ReturnType.VALUE, Collections.emptyList());

    Redisson 完全支持 Spring Cache 抽象.
    每个 Cache 实例具有两个重要参数: ttlmaxIdleTime
    且在它们没有定义或者等于 0 时会永久存储。
    配置示例:

    1. @Configuration
    2. @EnableCaching
    3. @Bean(destroyMethod="shutdown")
    4. RedissonClient redisson(@Value("classpath:/redisson.json") Resource configFile) throws IOException {
    5. Config config = Config.fromJSON(configFile.getInputStream());
    6. return Redisson.create(config);
    7. }
    8. @Bean
    9. CacheManager cacheManager(RedissonClient redissonClient) throws IOException {
    10. return new RedissonSpringCacheManager(redissonClient, "classpath:/cache-config.json");
    11. }
    12. }

    Redisson 使用高性能异步且无锁的 Redis 客户端。
    它支持异步和同步模式。
    如果 Redisson 尚不支持,你可以通过它自行执行命令。
    当然,在使用底层客户端之前,你可能想在 查询一下。