https://github.com/mindreframer/sqlcache
SQLite based cache with namespacing for Elixir
https://github.com/mindreframer/sqlcache
caching elixir sqlite
Last synced: about 1 year ago
JSON representation
SQLite based cache with namespacing for Elixir
- Host: GitHub
- URL: https://github.com/mindreframer/sqlcache
- Owner: mindreframer
- Created: 2023-02-27T21:58:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-21T20:47:33.000Z (about 2 years ago)
- Last Synced: 2025-02-09T19:14:12.383Z (about 1 year ago)
- Topics: caching, elixir, sqlite
- Language: Elixir
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Sqlcache
Very slim wrapper around `exqlite` to expose a key/value API with namespacing. Useful for local caching
## Usage
1. Add to children in `application.ex`:
```elixir
children = [
...
{Sqlcache, []},
...
]
```
2. (Optional) - Configure root_dir for Sqlite DB file in `config.exs`
```elixir
config :sqlcache, rootdir: "/tmp/sqlcache"
```
3. Start using
```elixir
:ok == Sqlcache.clear_kind("test")
{:ok, [], []} == Sqlcache.put("test", "a", 1)
{:ok, 1} == Sqlcache.get("test", "a")
{:ok, [], []} == Sqlcache.put("test", "a", %{a: 1, b: 2})
{:ok, %{a: 1, b: 2}} == Sqlcache.get("test", "a")
:ok == Sqlcache.clear_kind("test")
{:error, nil} == Sqlcache.get("test", "a")
```
## Installation
The package can be installed by adding `sqlcache` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:sqlcache, "~> 0.1.0"}
]
end
```
The docs can be found at .