Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
MVPArms
提交
f3518e2f
M
MVPArms
项目概览
门心叼龙
/
MVPArms
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
MVPArms
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f3518e2f
编写于
4月 13, 2018
作者:
J
JessYan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve Cache's comment
上级
dd3df902
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
23 deletion
+32
-23
arms/src/main/java/com/jess/arms/integration/cache/Cache.java
.../src/main/java/com/jess/arms/integration/cache/Cache.java
+13
-13
arms/src/main/java/com/jess/arms/integration/cache/IntelligentCache.java
...ava/com/jess/arms/integration/cache/IntelligentCache.java
+8
-8
arms/src/main/java/com/jess/arms/integration/cache/LruCache.java
...c/main/java/com/jess/arms/integration/cache/LruCache.java
+11
-2
未找到文件。
arms/src/main/java/com/jess/arms/integration/cache/Cache.java
浏览文件 @
f3518e2f
...
...
@@ -43,7 +43,7 @@ public interface Cache<K, V> {
* Returns a new cache
*
* @param type 框架中需要缓存的模块类型
* @return
* @return
{@link Cache}
*/
@NonNull
Cache
build
(
CacheType
type
);
...
...
@@ -52,22 +52,22 @@ public interface Cache<K, V> {
/**
* 返回当前缓存已占用的总 size
*
* @return
* @return
{@code size}
*/
int
size
();
/**
* 返回当前缓存所能允许的最大 size
*
* @return
* @return
{@code maxSize}
*/
int
getMaxSize
();
/**
* 返回这个 {@code key} 在缓存中对应的 {@code value}, 如果返回 {@code null} 说明这个 {@code key} 没有对应的 {@code value}
*
* @param key
* @return
* @param key
{@code key}
* @return
{@code value}
*/
@Nullable
V
get
(
K
key
);
...
...
@@ -76,9 +76,9 @@ public interface Cache<K, V> {
* 将 {@code key} 和 {@code value} 以条目的形式加入缓存,如果这个 {@code key} 在缓存中已经有对应的 {@code value}
* 则此 {@code value} 被新的 {@code value} 替换并返回,如果为 {@code null} 说明是一个新条目
*
* @param key
* @param value
* @return
* @param key
{@code key}
* @param value
{@code value}
* @return
如果这个 {@code key} 在容器中已经储存有 {@code value}, 则返回之前的 {@code value} 否则返回 {@code null}
*/
@Nullable
V
put
(
K
key
,
V
value
);
...
...
@@ -87,8 +87,8 @@ public interface Cache<K, V> {
* 移除缓存中这个 {@code key} 所对应的条目,并返回所移除条目的 value
* 如果返回为 {@code null} 则有可能时因为这个 {@code key} 对应的 value 为 {@code null} 或条目不存在
*
* @param key
* @return
* @param key
{@code key}
* @return
如果这个 {@code key} 在容器中已经储存有 {@code value} 并且删除成功则返回删除的 {@code value}, 否则返回 {@code null}
*/
@Nullable
V
remove
(
K
key
);
...
...
@@ -96,15 +96,15 @@ public interface Cache<K, V> {
/**
* 如果这个 {@code key} 在缓存中有对应的 value 并且不为 {@code null}, 则返回 {@code true}
*
* @param key
* @return
* @param key
{@code key}
* @return
{@code true} 为在容器中含有这个 {@code key}, 否则为 {@code false}
*/
boolean
containsKey
(
K
key
);
/**
* 返回当前缓存中含有的所有 {@code key}
*
* @return
* @return
{@code keySet}
*/
Set
<
K
>
keySet
();
...
...
arms/src/main/java/com/jess/arms/integration/cache/IntelligentCache.java
浏览文件 @
f3518e2f
/*
* Copyright 201
7
JessYan
* Copyright 201
8
JessYan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -68,7 +68,7 @@ public class IntelligentCache<V> implements Cache<String, V> {
}
/**
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为
其
前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
*
* @param key {@code key}
* @return {@code value}
...
...
@@ -83,7 +83,7 @@ public class IntelligentCache<V> implements Cache<String, V> {
}
/**
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为
其
前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
*
* @param key {@code key}
* @param value {@code value}
...
...
@@ -99,10 +99,10 @@ public class IntelligentCache<V> implements Cache<String, V> {
}
/**
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为
其
前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
*
* @param key {@code key}
* @return 如果
{@code key} 在容器中
有 {@code value} 并且删除成功则返回删除的 {@code value}, 否则返回 {@code null}
* @return 如果
这个 {@code key} 在容器中已经储存
有 {@code value} 并且删除成功则返回删除的 {@code value}, 否则返回 {@code null}
*/
@Nullable
@Override
...
...
@@ -114,7 +114,7 @@ public class IntelligentCache<V> implements Cache<String, V> {
}
/**
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
* 如果在 {@code key} 中使用 {@link #KEY_KEEP} 作为
其
前缀, 则操作 {@link #mMap}, 否则操作 {@link #mCache}
*
* @param key {@code key}
* @return {@code true} 为在容器中含有这个 {@code key}, 否则为 {@code false}
...
...
@@ -128,9 +128,9 @@ public class IntelligentCache<V> implements Cache<String, V> {
}
/**
* 将 {@link #mMap} 和 {@link #mCache} 的
keySet
合并返回
* 将 {@link #mMap} 和 {@link #mCache} 的
{@code keySet}
合并返回
*
* @return 合并后的
keySet
* @return 合并后的
{@code keySet}
*/
@Override
public
Set
<
String
>
keySet
()
{
...
...
arms/src/main/java/com/jess/arms/integration/cache/LruCache.java
浏览文件 @
f3518e2f
...
...
@@ -72,6 +72,7 @@ public class LruCache<K, V> implements Cache<K, V> {
* 子类可以重写这个方法以适应不同的单位,比如说 bytes
*
* @param item 每个 {@code item} 所占用的 size
* @return 单个 item 的 {@code size}
*/
protected
int
getItemSize
(
V
item
)
{
return
1
;
...
...
@@ -89,6 +90,8 @@ public class LruCache<K, V> implements Cache<K, V> {
/**
* 返回当前缓存所能允许的最大 size
*
* @return {@code maxSize}
*/
@Override
public
synchronized
int
getMaxSize
()
{
...
...
@@ -97,6 +100,8 @@ public class LruCache<K, V> implements Cache<K, V> {
/**
* 返回当前缓存已占用的总 size
*
* @return {@code size}
*/
@Override
public
synchronized
int
size
()
{
...
...
@@ -107,6 +112,7 @@ public class LruCache<K, V> implements Cache<K, V> {
* 如果这个 {@code key} 在缓存中有对应的 {@code value} 并且不为 {@code null},则返回 true
*
* @param key 用来映射的 {@code key}
* @return {@code true} 为在容器中含有这个 {@code key}, 否则为 {@code false}
*/
@Override
public
synchronized
boolean
containsKey
(
K
key
)
{
...
...
@@ -116,7 +122,7 @@ public class LruCache<K, V> implements Cache<K, V> {
/**
* 返回当前缓存中含有的所有 {@code key}
*
* @return
* @return
{@code keySet}
*/
@Override
public
Set
<
K
>
keySet
()
{
...
...
@@ -127,6 +133,7 @@ public class LruCache<K, V> implements Cache<K, V> {
* 返回这个 {@code key} 在缓存中对应的 {@code value}, 如果返回 {@code null} 说明这个 {@code key} 没有对应的 {@code value}
*
* @param key 用来映射的 {@code key}
* @return {@code value}
*/
@Override
@Nullable
...
...
@@ -143,6 +150,7 @@ public class LruCache<K, V> implements Cache<K, V> {
*
* @param key 通过这个 {@code key} 添加条目
* @param value 需要添加的 {@code value}
* @return 如果这个 {@code key} 在容器中已经储存有 {@code value}, 则返回之前的 {@code value} 否则返回 {@code null}
*/
@Override
@Nullable
...
...
@@ -170,6 +178,7 @@ public class LruCache<K, V> implements Cache<K, V> {
* 如果返回为 {@code null} 则有可能时因为这个 {@code key} 对应的 {@code value} 为 {@code null} 或条目不存在
*
* @param key 使用这个 {@code key} 移除对应的条目
* @return 如果这个 {@code key} 在容器中已经储存有 {@code value} 并且删除成功则返回删除的 {@code value}, 否则返回 {@code null}
*/
@Override
@Nullable
...
...
@@ -192,7 +201,7 @@ public class LruCache<K, V> implements Cache<K, V> {
/**
* 当指定的 size 小于当前缓存已占用的总 size 时,会开始清除缓存中最近最少使用的条目
*
* @param size
* @param size
{@code size}
*/
protected
synchronized
void
trimToSize
(
int
size
)
{
Map
.
Entry
<
K
,
V
>
last
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录