com.iqarr.redis.cache.RedisCache Maven / Gradle / Ivy
The newest version!
package com.iqarr.redis.cache;
import com.iqarr.cache.Cache;
import com.iqarr.redis.bin.utils.JedisBinUtils;
import com.iqarr.redis.exception.RedisException;
import com.iqarr.redis.string.utils.JedisStrUtils;
/**
*
*
*
*
* @since
* V1.0
* @author
* zhangyong
* @version
* V1.0
*/
public class RedisCache implements Cache {
/*
*
* @param key
*
* @param value
*
* @see com.iqarr.cache.Cache#put(java.lang.Object, java.lang.Object)
*/
@Override
public void put(Object key, Object value) {
try {
if (key instanceof String && value instanceof String) {
JedisStrUtils.set((String) key, (String) value);
}
else {
JedisBinUtils.set(key, value);
}
}
catch (RedisException e) {
throw new RuntimeException(e.getMsg(), e);
}
}
/*
* Title: put
* Title: getTtl
* Title: setTtl
* Title: get
* Title: get
* T get(Object key, Class clazz) {
Object object = get(key);
if (object == null) {
return null;
}
return (T) object;
}
/*
* Title: get
* T get(Object key, long ttl, Class clazz) {
setTtl(key, ttl);
return get(key, clazz);
}
/*
* Title: remove
* © 2015 - 2025 Weber Informatics LLC | Privacy Policy