本文整理汇总了Java中org.springframework.data.redis.cache.RedisCache类的典型用法代码示例。如果您正苦于以下问题:Java RedisCache类的具体用法?Java RedisCache怎么用?Java RedisCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RedisCache类属于org.springframework.data.redis.cache包,在下文中一共展示了RedisCache类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
@Override
protected RedisCache createCache(String cacheName) {
// if(cacheName.equals("token")) {
// return new RedisCache(cacheName, "token:".getBytes(), this.ops, 24*60*60);
// }
return super.createCache(cacheName);
}
示例2: getCacheStatistics
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
@Override
public CacheStatistics getCacheStatistics(CacheManager cacheManager, RedisCache cache) {
DefaultCacheStatistics statistics = new DefaultCacheStatistics();
// @see http://redis.io/commands/INFO
RedisConnection connection = RedisConnectionUtils.getConnection(this.redisConnectionFactory);
try {
Properties props = connection.info();
Long hitCount = Long.parseLong(props.getProperty("keyspace_hits"));
Long missCount = Long.parseLong(props.getProperty("keyspace_misses"));
statistics.setGetCacheCounts(hitCount, missCount);
} finally {
RedisConnectionUtils.releaseConnection(connection, this.redisConnectionFactory);
}
return statistics;
}
示例3: getMissingCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
@Override
protected Cache getMissingCache(String name) {
RedisTemplate<? extends Object, ? extends Object> template = this.templates.get(name);
Long expiration = this.expires.get(name);
RedisCache cache = createCache(name, template, expiration);
return cache;
}
示例4: withCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
public RedisCacheManager withCache(String cacheName, RedisTemplate template, long expiration) {
this.templates.put(cacheName, template);
this.expires.put(cacheName, expiration);
RedisCache cache = createCache(cacheName, template, expiration);
addCache(cache);
return this;
}
示例5: init
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
public void init() {
template = SpringUtil.getBean("redisTemplate");//RedisCacheConfig中定义了
cache = new RedisCache(CACHE_NAME, CACHE_NAME.getBytes(), template, EXPIRE_TIME);
}
示例6: createCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
protected RedisCache createCache(String cacheName) {
long expiration = computeExpiration(cacheName);
return new CustomRedisCache(cacheName, (isUsePrefix() ? getCachePrefix().prefix(cacheName) : null),
getRedisOperations(), expiration);
}
示例7: createCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
protected RedisCache createCache(String cacheName, RedisTemplate<? extends Object, ? extends Object> template, long expiration) {
return new RedisCache(cacheName, (usePrefix ? cachePrefix.prefix(cacheName) : null), template, expiration);
}
示例8: createCache
import org.springframework.data.redis.cache.RedisCache; //导入依赖的package包/类
protected RedisCache createCache(String cacheName, RedisTemplate template, long expiration) {
return new RedisCache(cacheName, (usePrefix ? cachePrefix.prefix(cacheName) : null), template, expiration);
}