Skip to content

sephiroth74/SimpleLruCache

Repository files navigation

SimpleLruCache

Simple LruCache for Android

Build Status

Maven Central

Installation

Add the library dependency:

implementation 'it.sephiroth.android.library.cache:simple-lru-cache:**version**'

Usage

    // creates a new string lru-cache of 3 elements max 
    val cache = LruCache<String>(3)
    
    cache[0] = "first"
    cache[1] = "second"
    cache[2] = "third"
    cache[3] = "fourth" // key `0` is removed
    
    val entry = cache[1] // returns `second`
    val entry2 = cache[0] // returns null
    
    cache.erase(1) // key `1` is removed (now size is 2)