From b013ec996b7470fd8307e971a133f8b6f6446ce4 Mon Sep 17 00:00:00 2001 From: pingerx Date: Fri, 15 Feb 2019 14:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=AD=A5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- rxcache/src/main/java/com/zchu/rxcache/RxCache.java | 9 +++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d8a7091..ba94837 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,11 @@ public enum CacheTarget { }); ``` +同步获取缓存: +```java + CacheResult = rxCache.loadSync("test_key1", String.class); +``` + ## 混淆配置 diff --git a/build.gradle b/build.gradle index 03531fd..e83ffc9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.21' repositories { jcenter() maven { @@ -11,7 +11,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' classpath "guru.stefma.bintrayrelease:bintrayrelease:1.1.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ccd2aa9..1bbdbc9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,8 +1,8 @@ -#Tue Nov 06 15:49:27 CST 2018 +#Fri Feb 15 13:36:39 SGT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists org.gradle.daemon=true -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip org.gradle.parallel=true diff --git a/rxcache/src/main/java/com/zchu/rxcache/RxCache.java b/rxcache/src/main/java/com/zchu/rxcache/RxCache.java index 1c3d70d..419581c 100644 --- a/rxcache/src/main/java/com/zchu/rxcache/RxCache.java +++ b/rxcache/src/main/java/com/zchu/rxcache/RxCache.java @@ -95,6 +95,15 @@ public Publisher> apply(Flowable flowable) { } + /** + * 同步读取缓存 + * 会阻塞主线程,请在子线程调用 + */ + public CacheResult loadSync(final String key, final Type type) { + return cacheCore.load(getMD5MessageDigest(key), type); + } + + /** * 读取 */