Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 1b58b1b

Browse files
authored
Merge pull request #31 from pingerx/master
添加同步获取缓存
2 parents b9541ae + b013ec9 commit 1b58b1b

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ public enum CacheTarget {
218218
});
219219
```
220220

221+
同步获取缓存:
222+
```java
223+
CacheResult<String> = rxCache.<String>loadSync("test_key1", String.class);
224+
```
225+
221226

222227

223228
## 混淆配置

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.2.71'
4+
ext.kotlin_version = '1.3.21'
55
repositories {
66
jcenter()
77
maven {
@@ -11,7 +11,7 @@ buildscript {
1111
google()
1212
}
1313
dependencies {
14-
classpath 'com.android.tools.build:gradle:3.2.1'
14+
classpath 'com.android.tools.build:gradle:3.3.0'
1515

1616
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1717
classpath "guru.stefma.bintrayrelease:bintrayrelease:1.1.1"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#Tue Nov 06 15:49:27 CST 2018
1+
#Fri Feb 15 13:36:39 SGT 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
66
org.gradle.daemon=true
7-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
7+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
88
org.gradle.parallel=true

rxcache/src/main/java/com/zchu/rxcache/RxCache.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ public Publisher<CacheResult<T>> apply(Flowable<T> flowable) {
9595
}
9696

9797

98+
/**
99+
* 同步读取缓存
100+
* 会阻塞主线程,请在子线程调用
101+
*/
102+
public <T> CacheResult<T> loadSync(final String key, final Type type) {
103+
return cacheCore.load(getMD5MessageDigest(key), type);
104+
}
105+
106+
98107
/**
99108
* 读取
100109
*/

0 commit comments

Comments
 (0)