All Projects → blemale → Scaffeine

blemale / Scaffeine

Licence: apache-2.0
Thin Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine)

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Scaffeine

Ansible Role Memcached
Ansible Role - Memcached
Stars: ✭ 54 (-72.31%)
Mutual labels:  cache, caching, performance
Bigcache
Efficient cache for gigabytes of data written in Go.
Stars: ✭ 5,304 (+2620%)
Mutual labels:  cache, caching, performance
Craft Blitz
Intelligent static page caching for creating lightning-fast sites with Craft CMS.
Stars: ✭ 118 (-39.49%)
Mutual labels:  cache, performance
Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (-37.44%)
Mutual labels:  cache, caching
Fragment Cache
WordPress plugin for partial and async caching.
Stars: ✭ 135 (-30.77%)
Mutual labels:  cache, performance
Node Cache
a node internal (in-memory) caching module
Stars: ✭ 1,660 (+751.28%)
Mutual labels:  cache, caching
Quitnow Cache
A collection to store data for a given time
Stars: ✭ 109 (-44.1%)
Mutual labels:  cache, performance
Sequelize Transparent Cache
Simple to use and universal cache layer for Sequelize
Stars: ✭ 137 (-29.74%)
Mutual labels:  cache, caching
Cashew
A simple and elegant yet powerful HTTP client cache for .NET
Stars: ✭ 70 (-64.1%)
Mutual labels:  cache, caching
Nuster
A high performance HTTP proxy cache server and RESTful NoSQL cache server based on HAProxy
Stars: ✭ 1,825 (+835.9%)
Mutual labels:  cache, caching
Ngx Cache
Cache utility for Angular
Stars: ✭ 144 (-26.15%)
Mutual labels:  cache, caching
Libcache
A Lightweight in-memory key:value cache library for Go.
Stars: ✭ 152 (-22.05%)
Mutual labels:  cache, caching
Fast React Render
[DEPRECATED] Use last versions of React and Node.js for better performance
Stars: ✭ 102 (-47.69%)
Mutual labels:  cache, performance
Trickster
Open Source HTTP Reverse Proxy Cache and Time Series Dashboard Accelerator
Stars: ✭ 1,306 (+569.74%)
Mutual labels:  caching, performance
Laravel Blink
Cache that expires in the blink of an eye
Stars: ✭ 114 (-41.54%)
Mutual labels:  cache, performance
Minicache
📦 Python memory caching utilities
Stars: ✭ 79 (-59.49%)
Mutual labels:  cache, caching
Laravel Responsecache
Speed up a Laravel app by caching the entire response
Stars: ✭ 1,874 (+861.03%)
Mutual labels:  cache, performance
Haproxy
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Stars: ✭ 2,463 (+1163.08%)
Mutual labels:  cache, caching
Kirby3 Autoid
Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
Stars: ✭ 58 (-70.26%)
Mutual labels:  cache, performance
Efsecondlevelcache
Entity Framework 6.x Second Level Caching Library.
Stars: ✭ 63 (-67.69%)
Mutual labels:  caching, performance

Build Status Coverage Status Maven Central License Known Vulnerabilities

Scaffeine

A thin Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine).

Browse the API docs for the latest release.

Motivations

Caffeine is an awesome Java caching library. It has an impressive performance and a neat Java 8 API.

However the API does not play very well with Scala. So this is the thinner wrapper we can came with to make Caffeine easy and idiomatic to use in Scala.

API

Cache

"Cache" should "be created from Scaffeine builder" in {
    import com.github.blemale.scaffeine.{ Cache, Scaffeine }
    import scala.concurrent.duration._

    val cache: Cache[Int, String] =
      Scaffeine()
        .recordStats()
        .expireAfterWrite(1.hour)
        .maximumSize(500)
        .build[Int, String]()

    cache.put(1, "foo")

    cache.getIfPresent(1) should be(Some("foo"))
    cache.getIfPresent(2) should be(None)
  }

LoadingCache

"LoadingCache" should "be created from Scaffeine builder" in {
    import com.github.blemale.scaffeine.{ LoadingCache, Scaffeine }
    import scala.concurrent.duration._

    val cache: LoadingCache[Int, String] =
      Scaffeine()
        .recordStats()
        .expireAfterWrite(1.hour)
        .maximumSize(500)
        .build((i: Int) => s"foo$i")

    cache.get(1) should be("foo1")
  }

AsyncLoadingCache

 "AsyncLoadingCache" should "be created from Scaffeine builder with synchronous loader" in {
    import com.github.blemale.scaffeine.{ AsyncLoadingCache, Scaffeine }
    import scala.concurrent.duration._

    val cache: AsyncLoadingCache[Int, String] =
      Scaffeine()
        .recordStats()
        .expireAfterWrite(1.hour)
        .maximumSize(500)
        .buildAsync((i: Int) => s"foo$i")

    whenReady(cache.get(1)) { value =>
      value should be("foo1")
    }
  }

"AsyncLoadingCache" should "be created from Scaffeine builder with asynchronous loader" in {
    import com.github.blemale.scaffeine.{ AsyncLoadingCache, Scaffeine }
    import scala.concurrent.duration._

    val cache: AsyncLoadingCache[Int, String] =
      Scaffeine()
        .recordStats()
        .expireAfterWrite(1.hour)
        .maximumSize(500)
        .buildAsyncFuture((i: Int) => Future.successful(s"foo$i"))

    whenReady(cache.get(1)) { value =>
      value should be("foo1")
    }
  }

Download

Download from Maven Central or depend via SBT:

"com.github.blemale" %% "scaffeine" % "<version>" % "compile"

Snapshots of the development version are available in Sonatype's snapshots repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].