Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
bfc3a607
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bfc3a607
编写于
2月 24, 2020
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
LRUCacheMap optimization
上级
9b64a712
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
15 deletion
+14
-15
redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java
...on/src/main/java/org/redisson/cache/AbstractCacheMap.java
+5
-2
redisson/src/main/java/org/redisson/cache/Cache.java
redisson/src/main/java/org/redisson/cache/Cache.java
+0
-3
redisson/src/main/java/org/redisson/cache/LRUCacheMap.java
redisson/src/main/java/org/redisson/cache/LRUCacheMap.java
+9
-10
未找到文件。
redisson/src/main/java/org/redisson/cache/AbstractCacheMap.java
浏览文件 @
bfc3a607
...
...
@@ -178,8 +178,7 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
return
put
(
key
,
value
,
timeToLiveInMillis
,
TimeUnit
.
MILLISECONDS
,
maxIdleInMillis
,
TimeUnit
.
MILLISECONDS
);
}
@Override
public
V
put
(
K
key
,
V
value
,
long
ttl
,
TimeUnit
ttlUnit
,
long
maxIdleTime
,
TimeUnit
maxIdleUnit
)
{
private
V
put
(
K
key
,
V
value
,
long
ttl
,
TimeUnit
ttlUnit
,
long
maxIdleTime
,
TimeUnit
maxIdleUnit
)
{
CachedValue
<
K
,
V
>
entry
=
create
(
key
,
value
,
ttlUnit
.
toMillis
(
ttl
),
maxIdleUnit
.
toMillis
(
maxIdleTime
));
if
(
isFull
(
key
))
{
if
(!
removeExpiredEntries
())
{
...
...
@@ -205,6 +204,10 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
}
protected
boolean
removeExpiredEntries
()
{
if
(
timeToLiveInMillis
==
0
&&
maxIdleInMillis
==
0
)
{
return
false
;
}
boolean
removed
=
false
;
// TODO optimize
for
(
CachedValue
<
K
,
V
>
value
:
map
.
values
())
{
...
...
redisson/src/main/java/org/redisson/cache/Cache.java
浏览文件 @
bfc3a607
...
...
@@ -16,7 +16,6 @@
package
org.redisson.cache
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
/**
*
...
...
@@ -27,6 +26,4 @@ import java.util.concurrent.TimeUnit;
*/
public
interface
Cache
<
K
,
V
>
extends
Map
<
K
,
V
>
{
V
put
(
K
key
,
V
value
,
long
ttl
,
TimeUnit
ttlUnit
,
long
maxIdleTime
,
TimeUnit
maxIdleUnit
);
}
redisson/src/main/java/org/redisson/cache/LRUCacheMap.java
浏览文件 @
bfc3a607
...
...
@@ -15,13 +15,7 @@
*/
package
org.redisson.cache
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
...
...
@@ -83,16 +77,21 @@ public class LRUCacheMap<K, V> extends AbstractCacheMap<K, V> {
if
(
startIndex
==
-
1
)
{
startIndex
=
queueIndex
;
}
Collection
<
CachedValue
<
K
,
V
>>
queue
=
queues
.
get
(
queueIndex
);
CachedValue
<
K
,
V
>
removedValue
=
null
;
synchronized
(
queue
)
{
Iterator
<
CachedValue
<
K
,
V
>>
iter
=
queue
.
iterator
();
if
(
iter
.
hasNext
())
{
CachedValue
<
K
,
V
>
v
alue
=
iter
.
next
();
removedV
alue
=
iter
.
next
();
iter
.
remove
();
map
.
remove
(
value
.
getKey
(),
value
);
return
;
}
}
if
(
removedValue
!=
null
)
{
map
.
remove
(
removedValue
.
getKey
(),
removedValue
);
return
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录