8000 GitHub - andrewaylett/arc: Adaptive Replacement Cache with expiry and refresh
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andrewaylett/arc

Repository files navigation

ARC Library

ARC is an Adaptive Replacement Cache.

Originally intended for page table caches, this library makes the algorithm available for general use.

Values are always loaded in a separate thread, and (like Guava's cache) we will only load a value once. The common pool is used if no fork-join pool is provided.

While the cache only holds strong references to a limited number of values (up to the given capacity), it continues to hold weak references to all values it's loaded. If the garbage collector hasn't reclaimed the space, the cache will still return the value.

Expiry and Refresh

The cache can be configured to expire values, and also to refresh if a value has been re-used.

Both expiry time and refresh time are relative to the last time we completed loading the value successfully.

Usage

Include the library in your dependencies:

dependencies {
    implementation 'eu.aylett.arc:arc:0.1.0'
}

Build yourself a suitable cache:

import eu.aylett.arc.Arc;

public class ReadmeTest {
  public static void main(String[] args) {
    var arc = Arc.<Integer, String>build(i -> ("" + i).repeat(i), 1);
    assert arc.get(1).equals("1");
    assert arc.get(7).equals("7777777");
  }
}

About

Adaptive Replacement Cache with expiry and refresh

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •  

Languages

0