All Projects → whitfin → stash

whitfin / stash

Licence: MIT license
A small and user-friendly ETS wrapper for caching in Elixir

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to stash

Vuex Localstorage
Persist Vuex state with expires by localStorage or some else storage.
Stars: ✭ 129 (+152.94%)
Mutual labels:  persistence
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (+250.98%)
Mutual labels:  persistence
Data
ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).
Stars: ✭ 243 (+376.47%)
Mutual labels:  persistence
Arcanus
ARCANUS is a customized payload generator/handler.
Stars: ✭ 130 (+154.9%)
Mutual labels:  persistence
Lucid
High performance and distributed KV store w/ REST API. 🦀
Stars: ✭ 171 (+235.29%)
Mutual labels:  persistence
Technowhorse
TechNowHorse is a RAT (Remote Administrator Trojan) Generator for Windows/Linux systems written in Python 3.
Stars: ✭ 189 (+270.59%)
Mutual labels:  persistence
Litfs
A FUSE file system in Go extended with persistent file storage
Stars: ✭ 116 (+127.45%)
Mutual labels:  persistence
UserDefault
The simplest way of using the UserDefaults with @propertyWrapper.
Stars: ✭ 17 (-66.67%)
Mutual labels:  persistence
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (+245.1%)
Mutual labels:  persistence
Skopelos
A minimalistic, thread safe, non-boilerplate and super easy to use version of Active Record on Core Data. Simply all you need for doing Core Data. Swift flavour.
Stars: ✭ 231 (+352.94%)
Mutual labels:  persistence
Fluentdispatch
🌊 .NET Standard 2.1 framework which makes easy to scaffold distributed systems and dispatch incoming load into units of work in a deterministic way.
Stars: ✭ 152 (+198.04%)
Mutual labels:  persistence
Technowlogger
TechNowLogger is Windows/Linux Keylogger Generator which sends key-logs via email with other juicy target info
Stars: ✭ 172 (+237.25%)
Mutual labels:  persistence
Fancytree
JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
Stars: ✭ 2,398 (+4601.96%)
Mutual labels:  persistence
Ardb
A redis protocol compatible nosql, it support multiple storage engines as backend like Google's LevelDB, Facebook's RocksDB, OpenLDAP's LMDB, PerconaFT, WiredTiger, ForestDB.
Stars: ✭ 1,707 (+3247.06%)
Mutual labels:  persistence
client-side-databases
An implementation of the exact same app in Firestore, AWS Datastore, PouchDB, RxDB and WatermelonDB
Stars: ✭ 787 (+1443.14%)
Mutual labels:  persistence
Persistentstreamplayer
Stream audio over http, and persist the data to a local file while buffering
Stars: ✭ 120 (+135.29%)
Mutual labels:  persistence
Hydrated bloc
An extension to the bloc state management library which automatically persists and restores bloc states.
Stars: ✭ 181 (+254.9%)
Mutual labels:  persistence
Awesome-Android-Persistence
A curated list of awesome android persistence libraries about SQLite, ORM, Mobile Database, SharedPreferences, etc.
Stars: ✭ 69 (+35.29%)
Mutual labels:  persistence
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+47.06%)
Mutual labels:  persistence
Storagekit
Your Data Storage Troubleshooter 🛠
Stars: ✭ 225 (+341.18%)
Mutual labels:  persistence

Stash

Build Status

A very small wrapping implementation around ETS, providing a more user-friendly key/value interface for new users. Takes care of setting up a new ETS table as needed with a default set of options to avoid having to deal with configurations. This library is meant as a fast way to use ETS without anything flashy, so don't expect many features over what's already here (which isn't much, intentionally).

Installation

This package can be installed via Hex, just add stash to your list of dependencies in mix.exs:

def deps do
  [{:stash, "~> 1.0.0"}]
end

Quick Usage

It's straightforward to get going:

iex(1)> Stash.set(:my_cache, "my_key", "my_value")
true
iex(2)> Stash.get(:my_cache, "my_key")
"my_value"
iex(3)> Stash.delete(:my_cache, "my_key")
true
iex(4)> Stash.get(:my_cache, "my_key")
nil

For further examples, as well as the rest of the API, please see the documentation.

A Note On Table Configuration

By default, Stash will create a table with the following configuration:

[
  { :read_concurrency, true },
  { :write_concurrency, true },
  :public,
  :set,
  :named_table
]

If you don't wish to have this configuration, please create your ETS table in advance of using Stash to access it. However keep in mind that Stash is written with the assumption that you're using either a set or ordered_set, so it's best to stick to those. The defaults should be ok in most cases, so unless you're already thinking that you want a setting changed above, you're probably fine.

Persistence

A neat little feature is the ability to persist a cache to disk, by calling Stash.persist/2. This will move your ETS tables into DTS, allowing you to reload after your process has died. This is not kept in sync due to the overhead involved, so it might be an idea to schedule persistance if you rely on it. To reload, call Stash.load/2.

iex(1)> Stash.set(:my_cache, "key", "value")
true
iex(2)> Stash.size(:my_cache)
1
iex(3)> Stash.persist(:my_cache, "/tmp/my_persistence_file")
:ok
iex(4)> Stash.delete(:my_cache, "key")
true
iex(5)> Stash.size(:my_cache)
0
iex(6)> Stash.load(:my_cache, "/tmp/my_persistence_file")
:ok
iex(7)> Stash.size(:my_cache)
1
iex(1)> Stash.get(:my_cache, "key")
"value"

Issues/Contributions

If you spot any issues with the implementation, please file an issue or even a PR. Like I mentioned above, not too many features will make it into this lib as it's a small wrapping library, nothing special.

Make sure to test your changes though!

$ mix test --trace
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].