com.github.spring.RedisCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis-spring-support Show documentation
Show all versions of jedis-spring-support Show documentation
using jedis lib, add spring support
The newest version!
package com.github.spring;
import com.github.autoconf.helper.ConfigHelper;
import com.github.jedis.support.BinaryJedisCmd;
import com.github.trace.TraceContext;
import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.Cache;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.serializer.support.DeserializingConverter;
import org.springframework.core.serializer.support.SerializingConverter;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Set;
/**
* 用redis做cache存储
* Created by lirui on 2015/03/10 下午8:32.
*/
public class RedisCache implements Cache {
private static final Logger LOG = LoggerFactory.getLogger(RedisCache.class);
private static final Charset UTF8 = Charset.forName("UTF-8");
private static final byte[] EMPTY_ARRAY = new byte[0];
private static final int PAGE_SIZE = 128;
private final String name;
private final int expiration;
private final BinaryJedisCmd redis;
/**
* 给一个固定前缀,避免和其他有冲突
*/
private final byte[] prefix;
/**
* 把所有设定的key记录下来,方便做clearAll操作
*/
private final byte[] setName;
private Converter