Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
f5daa657
S
spring-framework
项目概览
sesemomo
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f5daa657
编写于
7月 17, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
9ffdf05d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
32 addition
and
30 deletion
+32
-30
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractCacheInterceptor.java
...rk/cache/jcache/interceptor/AbstractCacheInterceptor.java
+3
-3
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java
...k/cache/jcache/interceptor/CacheRemoveAllInterceptor.java
+3
-4
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java
...cache/jcache/interceptor/CacheRemoveEntryInterceptor.java
+3
-4
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperation.java
...mework/cache/jcache/interceptor/CacheRemoveOperation.java
+3
-3
spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java
...ork/cache/transaction/TransactionAwareCacheDecorator.java
+10
-7
spring-context/src/main/java/org/springframework/cache/Cache.java
...ontext/src/main/java/org/springframework/cache/Cache.java
+7
-6
spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java
...java/org/springframework/cache/annotation/CacheEvict.java
+1
-1
spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java
.../springframework/cache/concurrent/ConcurrentMapCache.java
+2
-2
未找到文件。
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractCacheInterceptor.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -59,7 +59,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
/**
* Resolve the cache to use.
* @param context the invocation context
* @return the cache to use (never
null
)
* @return the cache to use (never
{@code null}
)
*/
protected
Cache
resolveCache
(
CacheOperationInvocationContext
<
O
>
context
)
{
Collection
<?
extends
Cache
>
caches
=
context
.
getOperation
().
getCacheResolver
().
resolveCaches
(
context
);
...
...
@@ -73,7 +73,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
/**
* Convert the collection of caches in a single expected element.
* <p>Throw an {@link IllegalStateException} if the collection holds more than one element
* @return the single element or {@code null} if the collection is empty
* @return the single element
,
or {@code null} if the collection is empty
*/
@Nullable
static
Cache
extractFrom
(
Collection
<?
extends
Cache
>
caches
)
{
...
...
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllInterceptor.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -42,7 +42,6 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
CacheOperationInvocationContext
<
CacheRemoveAllOperation
>
context
,
CacheOperationInvoker
invoker
)
{
CacheRemoveAllOperation
operation
=
context
.
getOperation
();
boolean
earlyRemove
=
operation
.
isEarlyRemove
();
if
(
earlyRemove
)
{
removeAll
(
context
);
...
...
@@ -67,8 +66,8 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
protected
void
removeAll
(
CacheOperationInvocationContext
<
CacheRemoveAllOperation
>
context
)
{
Cache
cache
=
resolveCache
(
context
);
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Invalidating entire cache '"
+
cache
.
getName
()
+
"' for operation "
+
context
.
getOperation
());
logger
.
trace
(
"Invalidating entire cache '"
+
cache
.
getName
()
+
"' for operation "
+
context
.
getOperation
());
}
doClear
(
cache
);
}
...
...
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveEntryInterceptor.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -42,7 +42,6 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
CacheOperationInvocationContext
<
CacheRemoveOperation
>
context
,
CacheOperationInvoker
invoker
)
{
CacheRemoveOperation
operation
=
context
.
getOperation
();
boolean
earlyRemove
=
operation
.
isEarlyRemove
();
if
(
earlyRemove
)
{
removeValue
(
context
);
...
...
@@ -68,8 +67,8 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
Object
key
=
generateKey
(
context
);
Cache
cache
=
resolveCache
(
context
);
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Invalidating key ["
+
key
+
"] on cache '"
+
cache
.
getName
()
+
"' for operation "
+
context
.
getOperation
());
logger
.
trace
(
"Invalidating key ["
+
key
+
"] on cache '"
+
cache
.
getName
()
+
"' for operation "
+
context
.
getOperation
());
}
doEvict
(
cache
,
key
);
}
...
...
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperation.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -50,8 +50,8 @@ class CacheRemoveOperation extends AbstractJCacheKeyOperation<CacheRemove> {
}
/**
* Specify if the cache entry should be remove
before invoking the method. By default, the
* cache entry is removed after the method invocation.
* Specify if the cache entry should be remove
d before invoking the method.
*
<p>By default, the
cache entry is removed after the method invocation.
* @see javax.cache.annotation.CacheRemove#afterInvocation()
*/
public
boolean
isEarlyRemove
()
{
...
...
spring-context-support/src/main/java/org/springframework/cache/transaction/TransactionAwareCacheDecorator.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -25,14 +25,16 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
import
org.springframework.util.Assert
;
/**
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and {@link #clear}
* operations with Spring-managed transactions (through Spring's {@link TransactionSynchronizationManager},
* performing the actual cache put/evict/clear operation only in the after-commit phase of a
* successful transaction. If no transaction is active, {@link #put}, {@link #evict} and
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and
* {@link #clear} operations with Spring-managed transactions (through Spring's
* {@link TransactionSynchronizationManager}, performing the actual cache
* put/evict/clear operation only in the after-commit phase of a successful
* transaction. If no transaction is active, {@link #put}, {@link #evict} and
* {@link #clear} operations will be performed immediately, as usual.
*
* <p>Use of more aggressive operations such as {@link #putIfAbsent} cannot be deferred
* to the after-commit phase of a running transaction. Use these with care.
* <p><b>Note:</b> Use of immediate operations such as {@link #putIfAbsent}
* cannot be deferred to the after-commit phase of a running transaction.
* Use these with care in a transactional environment.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
...
...
@@ -54,6 +56,7 @@ public class TransactionAwareCacheDecorator implements Cache {
this
.
targetCache
=
targetCache
;
}
/**
* Return the target Cache that this Cache should delegate to.
*/
...
...
spring-context/src/main/java/org/springframework/cache/Cache.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -55,6 +55,7 @@ public interface Cache {
* a cached {@code null} value. A straight {@code null} being
* returned means that the cache contains no mapping for this key.
* @see #get(Object, Class)
* @see #get(Object, Callable)
*/
@Nullable
ValueWrapper
get
(
Object
key
);
...
...
@@ -94,6 +95,7 @@ public interface Cache {
* @return the value to which this cache maps the specified key
* @throws ValueRetrievalException if the {@code valueLoader} throws an exception
* @since 4.3
* @see #get(Object)
*/
@Nullable
<
T
>
T
get
(
Object
key
,
Callable
<
T
>
valueLoader
);
...
...
@@ -112,13 +114,11 @@ public interface Cache {
* if it is not set already.
* <p>This is equivalent to:
* <pre><code>
*
Object
existingValue = cache.get(key);
*
ValueWrapper
existingValue = cache.get(key);
* if (existingValue == null) {
* cache.put(key, value);
* return null;
* } else {
* return existingValue;
* }
* return existingValue;
* </code></pre>
* except that the action is performed atomically. While all out-of-the-box
* {@link CacheManager} implementations are able to perform the put atomically,
...
...
@@ -132,6 +132,7 @@ public interface Cache {
* mapping for that key prior to this call. Returning {@code null} is therefore
* an indicator that the given {@code value} has been associated with the key.
* @since 4.1
* @see #put(Object, Object)
*/
@Nullable
ValueWrapper
putIfAbsent
(
Object
key
,
@Nullable
Object
value
);
...
...
@@ -143,7 +144,7 @@ public interface Cache {
void
evict
(
Object
key
);
/**
*
Remove all mappings from the cache
.
*
Clear the cache through removing all mappings
.
*/
void
clear
();
...
...
spring-context/src/main/java/org/springframework/cache/annotation/CacheEvict.java
浏览文件 @
f5daa657
...
...
@@ -142,7 +142,7 @@ public @interface CacheEvict {
* occur irrespective of the method outcome (i.e., whether it threw an
* exception or not).
* <p>Defaults to {@code false}, meaning that the cache eviction operation
* will occur <em>after</em> the advised method is invoked successfully (i.e.
,
* will occur <em>after</em> the advised method is invoked successfully (i.e.
* only if the invocation did not throw an exception).
*/
boolean
beforeInvocation
()
default
false
;
...
...
spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCache.java
浏览文件 @
f5daa657
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -141,7 +141,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
@Override
@Nullable
public
<
T
>
T
get
(
Object
key
,
Callable
<
T
>
valueLoader
)
{
return
(
T
)
fromStoreValue
(
this
.
store
.
computeIfAbsent
(
key
,
r
->
{
return
(
T
)
fromStoreValue
(
this
.
store
.
computeIfAbsent
(
key
,
k
->
{
try
{
return
toStoreValue
(
valueLoader
.
call
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录