capuchin_crypt
- code :: https://github.com/halostatue/capuchin_crypt
- issues :: https://github.com/halostatue/capuchin_crypt/issues
An in-memory persistent cache for Gleam. Expensive to update, cheap to read. In
Erlang, this uses persistent_term; in JavaScript, values are stored in a
module level Map.
If you think you need this, think again — you probably don’t. As the warning at
the top of persistent_term says:
Persistent terms is an advanced feature and is not a general replacement for ETS tables. Before using persistent terms, make sure to fully understand the consequence to system performance when updating or deleting persistent terms.
This is something which is useful but fundamentally breaks the immutable data model of Gleam. This can be valuable, but should be used primarily for utility values that are expensive to compute but used frequently during execution possibly in tight loops. This includes terms like regular expressions.
Again: if you think you need this, think again — you probably don’t.
This library is named after the fantastic Capuchin Crypt in Rome.
Installation
gleam add capuchin_crypt@1
Example
import capuchin_crypt
pub fn main() {
capuchin_crypt.put(
"something:expensive",
something_expensive_worth_caching())
)
capuchin_crypt.get("something:expensive")
}
Further documentation can be found at https://hexdocs.pm/capuchin_crypt.
Semantic Versioning
capuchin_crypt follows Semantic Versioning 2.0.