Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Diefferson Santos committed May 14, 2019
2 parents 7dd6f5b + d3cb95f commit 7e79b50
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ allprojects {
And add next dependencies in the build.gradle of the module:
```gradle
dependencies {
implementation "com.github.diefferson:CoroutinesCache:0.2.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.26.1-eap13"
implementation "com.github.diefferson:CoroutinesCache:0.2.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
}
```
## Usage
Expand All @@ -57,14 +57,17 @@ CoroutinesCache exposes `asyncCache()` method to help use cache in a row.
Finally, instantiate the CouroutinesCache .

```kotlin
val myCache = CoroutinesCache(context)
val myCache = CoroutinesCache(context,lifecycleOwner = this)

//CachePolicy.EvictProvider to defines to local cache ou data source
val users:List<User> = myCache.asyncCache({restApi.getUsers()} , "usersKey", CachePolicy.EvictProvider(true)).await()

//CachePolicy.LifeCache to defines a time to expire cache
//CachePolicy.TimeCache to defines a time to expire cache
val user:User = myCache.asyncCache({restApi.getUser(id)} , "userKey"+id, CachePolicy.LifeCache(15, TimeUnit.MINUTES)).await()

//CachePolicy.LifecycleCache - Pass a LifecycleOwner in constructor, cache is deleted when lifecycle is destroyed
val user:User = myCache.asyncCache({restApi.getUser(id)} , "userKey"+id, CachePolicy.LifecycleCache).await()

```

## Author
Expand Down

0 comments on commit 7e79b50

Please sign in to comment.