本文整理匯總了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;
}