hardcache

Package Version Hex Docs

Hardcache is a Gleam module that provides primitives for caching key-value pairs in files and using files as caches.

Examples

import hardcache

import gleam/float
import gleam/option

pub fn main() {
  let cache = hardcache.new("./expensive", True)
  case hardcache.try_get(cache, "expensive_calculation") {
    Ok(option.None) -> {
      let _ =
        hardcache.try_set(cache, "expensive_calculation", float.to_string(0.1 +. 0.2))
    }
    _ -> Nil
  }
}

Installation

If available on the Hex package manager, you can add hardcache to your project by running the command below:

gleam add hardcache

Further documentation can be found at https://hexdocs.pm/hardcache.

Development

gleam test # Run the tests
Search Document