Erlang (and by extension, Elixir) comes with a sweet little memory storage library called ETS (Erlang Term Storage). This provides an awesome way to store a whole bunch of values in memory, without having to write your own implementation, or pull in large third-party libraries.

The issue with ETS is that it's quite steep to get into for those new to Elixir, and with little-to-no knowledge of Erlang. The documentation is naturally based around Erlang, and so it's sometimes hard to understand exactly how to interact with the APIs.

Because of this, I decided to write Stash. Stash is a small wrapping library around ETS which allows for a friendly and familiar interface when using ETS. It's designed to be extremely bare and sit on top of ETS without providing any overhead. Due to this there isn't a wide "feature set" beyond the features already provided by ETS. I'm currently working on a much larger caching system, but decided that Stash has a place in the Elixir ecosystem, and so stripped it down and released it as a module.

Here's a quick glance at the API basics:

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

One of the more notable features is that you can persist your in-memory storage to disk as required (and vice-versa). This means that you can register handlers in your application and persist your cache before termination, and then reload it from disk on startup. All of this happens through this simple API:

iex(1)> filename = "/tmp/my_disk_file"
iex(2)> Stash.persist(:my_cache, filename)
iex(3)> Stash.load(:my_cache, filename)

Go ahead and check it out, and let me know your thoughts! Documentation lives on Hex, and feel free to ping me with any questions or issues.