RxCache 是一款支持 Java 和 Android 的 Local Cache 。目前支持内存、堆外内存、磁盘缓存。
- 拥有二级缓存:Memory、Persistence
- 各个缓存可以拥有有效时间,超过时间缓存会过期
- Memory 默认支持 FIFO、LRU、LFU 算法的实现
- Memory 额外支持 Guava Cache、Caffeine、MapDB 的实现
- Memory 支持显示缓存使用的统计数据。
- Memory 支持堆外内存(off-heap)
- Persistence 默认使用 Gson 实现对象的序列化和反序列化
- Persistence 额外支持使用 Fastjson、Moshi、Kryo、Hessian、FST 实现对象的序列化和反序列化
- Persistence 的 DiskImpl 拥有加密功能,默认使用 AES 128、DES 算法进行加密
- 使用 kotlin extension 模块,可以规避范型擦除
- 使用 Builder 模式生成 Type
- 线程安全
- 支持 RxJava 2
- 支持 Retrofit 风格使用缓存
更详细的功能请查看wiki
对于 Java 工程,如果使用 gradle 构建,由于默认没有使用 jcenter(),需要在相应 module 的 build.gradle 中配置
repositories {
mavenCentral()
jcenter()
}
rxcache-core
implementation 'com.safframework.rxcache:rxcache-core:1.4.3'
rxcache-proxy
implementation 'com.safframework.rxcache:rxcache-proxy:1.4.3'
rxcache-extension
implementation 'com.safframework.rxcache:rxcache-extension:1.4.3'
rxcache-memory-guava-cache
implementation 'com.safframework.rxcache:rxcache-memory-guava-cache:1.4.3'
rxcache-memory-caffeine
implementation 'com.safframework.rxcache:rxcache-memory-caffeine:1.4.3'
rxcache-memory-off-heap
implementation 'com.safframework.rxcache:rxcache-memory-off-heap:1.4.3'
rxcache-memory-mapdb
implementation 'com.safframework.rxcache:rxcache-memory-mapdb:1.4.3'
rxcache-converter-fastjson
implementation 'com.safframework.rxcache:rxcache-converter-fastjson:1.4.3'
rxcache-converter-moshi
implementation 'com.safframework.rxcache:rxcache-converter-moshi:1.4.3'
rxcache-converter-kryo
implementation 'com.safframework.rxcache:rxcache-converter-kryo:1.4.3'
rxcache-converter-hessian
implementation 'com.safframework.rxcache:rxcache-converter-hessian:1.4.3'
rxcache-converter-fst
implementation 'com.safframework.rxcache:rxcache-converter-fst:1.4.3'
- 参考了RxCache的实现
- 参考了RxCache的实现
- 参考了TypeBuilder的实现
- 重构 Disk 的实现
Wechat:fengzhizi715
Java与Android技术栈:每周更新推送原创技术文章,欢迎扫描下方的公众号二维码并关注,期待与您的共同成长和进步。
Copyright (C) 2018 - present, Tony Shen.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.