https://github.com/pedneri1/elixir_s3_cached
Key/value access to AWS S3 with in-memory cache
https://github.com/pedneri1/elixir_s3_cached
cache elixir key-value s3
Last synced: about 1 year ago
JSON representation
Key/value access to AWS S3 with in-memory cache
- Host: GitHub
- URL: https://github.com/pedneri1/elixir_s3_cached
- Owner: Pedneri1
- License: mit
- Created: 2021-01-25T02:10:57.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-07T21:31:05.000Z (over 5 years ago)
- Last Synced: 2025-04-05T03:03:22.372Z (about 1 year ago)
- Topics: cache, elixir, key-value, s3
- Language: Elixir
- Homepage: https://hex.pm/packages/elixir_s3_cached
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ElixirS3Cached
**TODO: Add description**
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `elixir_s3_cached` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:elixir_s3_cached, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/elixir_s3_cached](https://hexdocs.pm/elixir_s3_cached).
## Using in your project
If you want to start the cache manually, you can call `ElixirS3Cached.start_link/3`
```elixir
{:ok, cache} = ElixirS3Cached.start_link("elixir-s3-cache", %{})
```
and then, call the function `get/2`
```elixir
value = ElixirS3Cached.get(cache, "key")
```
or `set/3`
```elixir
ElixirS3Cached.set(cache, "key", "value")
```
### There is an optional parameter if you want to use a prefix.
```elixir
{:ok, cache} = ElixirS3Cached.start_link("elixir-s3-cache", %{}, "prefix")
```
Under the hood the lib will prepend the given prefix to every key. So if you call the `get/2` function with a "my-file.json" key it will look for "prefix/my-file.json" inside S3.
If you want to invalidate the entire cache you can use the `clear/1` function:
```elixir
ElixirS3Cached.clear(cache)
```
## Benchmarks
There are some benchmarkes available made with [Benchee](https://github.com/bencheeorg/benchee). You can find the script file under the `benchmarks/` directory. To run the benchmarks use the following command:
```
$ mix bench
```