本文整理汇总了Java中org.springframework.cache.Cache.put方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.put方法的具体用法?Java Cache.put怎么用?Java Cache.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cache.Cache
的用法示例。
在下文中一共展示了Cache.put方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPut
import org.springframework.cache.Cache; //导入方法依赖的package包/类
@Test
public void testPut() throws Exception {
Cache proxy = new ConcurrentMapCache("foo");
proxy.put("bar", "value");
proxy.put("baz", "value");
FluuzCache fluuzCache = new FluuzCache(eventManager, proxy);
eventManager.register(fluuzCache);
Thread.sleep(2000);
eventManager.evict("foo", "bar");
Thread.sleep(2000);
String value = null;
ValueWrapper vw = proxy.get("bar");
if (vw == null) {
}
System.out.println("->" + value);
}
示例2: updateCache
import org.springframework.cache.Cache; //导入方法依赖的package包/类
@AfterReturning ("@annotation(fr.gael.dhus.spring.cache.IncrementCache)")
public void updateCache (JoinPoint joinPoint)
{
IncrementCache annotation = ((MethodSignature) joinPoint.getSignature ())
.getMethod ().getAnnotation (IncrementCache.class);
Cache cache = getCacheManager().getCache(annotation.name());
if (cache != null)
{
synchronized (cache)
{
Integer old_value = cache.get (annotation.key (), Integer.class);
cache.clear ();
if (old_value == null)
{
return;
}
cache.put (annotation.key (), (old_value + annotation.value ()));
}
}
}
示例3: validateTmpUser
import org.springframework.cache.Cache; //导入方法依赖的package包/类
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
public void validateTmpUser (String code)
{
User u = userDao.getUserFromUserCode (code);
if (u != null && userDao.isTmpUser (u))
{
userDao.registerTmpUser (u);
// update cache entries
Cache cache = cacheManager.getCache("user");
if (cache != null)
{
synchronized (cache)
{
if (cache.get(u.getUUID()) != null)
{
cache.put(u.getUUID(), u);
}
}
}
cache = cacheManager.getCache("userByName");
if (cache != null)
{
synchronized (cache)
{
if (cache.get(u.getUsername()) != null)
{
cache.put(u.getUsername(), u);
}
}
}
}
}
示例4: apply
import org.springframework.cache.Cache; //导入方法依赖的package包/类
public void apply(Object result) {
if (this.context.canPutToCache(result)) {
for (Cache cache : this.context.getCaches()) {
cache.put(this.key, result);
}
}
}
示例5: putToCache
import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
* 向缓存中添加 缓存数据
*
* @param cache Cache
* @param key Cache key
* @param value Cache value, null will return false
* @return True is successful,otherwise false
*/
protected boolean putToCache(Cache cache, Object key, Object value) {
if (value == null) {
LOG.debug("Ignore put to cache[{}], key = {}, because value is null", cache, key);
return false;
}
cache.put(key, value);
LOG.debug("Put [{} = {}] to cache[{}]", key, value, cache);
return true;
}
示例6: putCache
import org.springframework.cache.Cache; //导入方法依赖的package包/类
/**
* 设置缓存数据
* @param cache
* @param key
* @param value
* @return
*/
protected boolean putCache(Cache cache, String key, Object value) {
if (null == value) {
return false;
}
cache.put(key, value);
return true;
}