#cache #actor-model #key #upstream #read-write #in-memory

thingvellir

a concurrent, shared-nothing abstraction that manages an assembly of things

37 releases

0.0.13 Mar 29, 2024
0.0.11 Dec 19, 2023
0.0.9 Sep 1, 2023
0.0.7 Apr 6, 2023
0.0.0-alpha9 Mar 9, 2020

#133 in Concurrency

Download history 64/week @ 2023-12-23 4227/week @ 2023-12-30 5434/week @ 2024-01-06 4359/week @ 2024-01-13 8818/week @ 2024-01-20 6249/week @ 2024-01-27 7760/week @ 2024-02-03 9888/week @ 2024-02-10 2576/week @ 2024-02-17 11307/week @ 2024-02-24 4549/week @ 2024-03-02 9064/week @ 2024-03-09 8083/week @ 2024-03-16 12466/week @ 2024-03-23 15366/week @ 2024-03-30 3389/week @ 2024-04-06

41,505 downloads per month

MIT license

165KB
3.5K SLoC

Þingvellir (thingvellir)

Build Status License Documentation Cargo

A rust library that allows you to build an in-memory write/read-through cache. It uses a sharded, shared-nothing actor model underneath ontop of tokio.

Given a struct, and an upstream, this abstraction handles the loading and committing of data. thingvellir is meant to sit in-front of a database (e.g. cassandra, or scylladb), providing a way to allow for in-memory caching of "hot" data within the database.

thingvellir exposes a key/value interface, abstracting away the database load and persist operations, allowing you to write your business logic as a simple struct that can be persisted to a database. Out of the box, thingvellir provides an upstream implementation, that will persist structs to cassandra, using a simple key/value schema, where the value is the CBOR serialized form, using serde.

thingvellir handles object expiry, as well allowing a bounded in-memory data-set (the # of keys the thingvellir will cache can be configured), and keys are able to be evicted as they expire (we use a random expiration probe similar to Redis), and also maintains a probabilistic LRU to evict keys if the cache is at capacity.

thingvellir coalesces reads and writes to the upstream data store. If your data model is amenable to delayed write durability (for example, counters that you are okay with data loss if the node crashes before data is committed upstream). Or a "hot" key might get queried a lot, or see a burst of queries, thingvellir will ensure that the upstream only sees a single read query. The write durability can be configured on a per-mutation basis, allowing for immediate commit, or delayed commit (depending on how much data-loss your application can tolerate.)

Dependencies

~5–17MB
~193K SLoC