Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/penemue/kaches
https://github.com/penemue/kaches
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/penemue/kaches
- Owner: penemue
- License: apache-2.0
- Created: 2018-02-07T14:08:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T11:38:10.000Z (almost 7 years ago)
- Last Synced: 2024-10-07T20:41:09.616Z (3 months ago)
- Language: Kotlin
- Size: 69.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# Kaches
[![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![Pure Kotlin](https://img.shields.io/badge/100%25-kotlin-orange.svg)](https://kotlinlang.org)Generic caches written in [Kotlin](https://kotlinlang.org).
Create cache with `LRU` eviction having maximum `1000` items:
```Kotlin
val cache = cache {
eviction = Eviction.LRU
size = 1000
getValue = { key -> key.toString() }
}
```Create cache with `RANDOM` eviction having maximum `1000` items:
```Kotlin
val cache = cache {
eviction = Eviction.RANDOM
size = 1000
getValue = { key -> key.toString() }
}
```Create cache with `LIFE_TIME` eviction with cached values living one second:
```Kotlin
val cache = cache {
eviction = Eviction.LIFE_TIME
lifeTime = 1000
getValue = { key -> key.toString() }
currentTimeMillis = { System.currentTimeMillis() }
}
```Create cache with `IDLE_TIME` eviction with cached values evicted after being unused for one second:
```Kotlin
val cache = cache {
eviction = Eviction.IDLE_TIME
idleTime = 1000
getValue = { key -> key.toString() }
currentTimeMillis = { System.currentTimeMillis() }
}
```