#tokio #assembly #concurrent #cache #actor #build #abstraction #model #in-memory

thingvellir

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

26 releases

0.0.4-alpha0 Apr 8, 2021
0.0.3-alpha0 Jan 14, 2021
0.0.2-alpha3 Oct 27, 2020
0.0.2-alpha2 Sep 1, 2020
0.0.0-alpha9 Mar 9, 2020

#57 in Concurrency

Download history 902/week @ 2021-04-04 779/week @ 2021-04-11 554/week @ 2021-04-18 391/week @ 2021-04-25 535/week @ 2021-05-02 598/week @ 2021-05-09 915/week @ 2021-05-16 730/week @ 2021-05-23 452/week @ 2021-05-30 504/week @ 2021-06-06 588/week @ 2021-06-13 575/week @ 2021-06-20 598/week @ 2021-06-27 37/week @ 2021-07-04 684/week @ 2021-07-11 731/week @ 2021-07-18

2,437 downloads per month

MIT license

145KB
3K 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.5MB
~100K SLoC