All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feingto.cloud.cache.RedisManager Maven / Gradle / Ivy

There is a newer version: 2.5.2.RELEASE
Show newest version
package com.feingto.cloud.cache;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.data.redis.connection.RedisConnectionCommands;
import org.springframework.data.redis.core.*;

/**
 * Redis 缓存管理器
 *
 * @author longfei
 */
@Accessors(chain = true)
public class RedisManager {
    @Getter
    @Setter
    private RedisTemplate template;

    public ValueOperations getValueStore() {
        return template.opsForValue();
    }

    public HashOperations getHashStore() {
        return template.opsForHash();
    }

    public ListOperations getListStore() {
        return template.opsForList();
    }

    public SetOperations getSetStore() {
        return template.opsForSet();
    }

    public ZSetOperations getZSetStore() {
        return template.opsForZSet();
    }

    public ClusterOperations getClusterStore() {
        return template.opsForCluster();
    }

    public HyperLogLogOperations getHyperLogLogStore() {
        return template.opsForHyperLogLog();
    }

    public String getPing() {
        return (String) template.execute((RedisCallback) RedisConnectionCommands::ping);
    }
}