Skip to content

Commit

Permalink
Add shortcuts for when Key is Unit (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmook authored Feb 21, 2021
1 parent 2190767 commit 057c21d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions layercache/src/main/kotlin/com/appmattus/layercache/Cache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,7 @@ public interface Cache<Key : Any, Value : Any> {
public fun <K : Any, V : Any> cache(block: suspend (K) -> V): Fetcher<K, V> = object : Fetcher<K, V> {
override suspend fun get(key: K) = block(key)
}

public suspend fun <Value : Any> Cache<Unit, Value>.get(): Value? = get(Unit)

public suspend fun <Value : Any> Cache<Unit, Value>.set(value: Value): Unit = set(Unit, value)

0 comments on commit 057c21d

Please sign in to comment.