Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmzeeman/rrets
Round Robin Erlang Term Storage
https://github.com/mmzeeman/rrets
Last synced: about 16 hours ago
JSON representation
Round Robin Erlang Term Storage
- Host: GitHub
- URL: https://github.com/mmzeeman/rrets
- Owner: mmzeeman
- License: apache-2.0
- Created: 2014-09-17T13:02:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T19:50:07.000Z (about 10 years ago)
- Last Synced: 2024-11-16T06:50:13.599Z (about 2 months ago)
- Language: Erlang
- Size: 191 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RRets - Round Robin Erlang Term Storage #
Copyright (c) 2014 MM Zeeman, All Rights Reserved.
### Introduction ###
The RRets packages allows for an easy way to store erlang terms into a round robin database. The
terms are stored until the storage has reached a predefined maximum and are then overwritten by newer items.Each term added to the storage gets a second resolution unix_time timestamp attached to it.
The storage can be used to easily, and quickly, store terms. Example usage:* Logs
* System statistics
* Audit logsThe storage can be queried with a match specification which allows quick, and streaming, access
to your data.For example:
```erlang
MatchSpec = ets:fun2ms(fun({Timestamp, {example, 2, X}}) -> {Timestamp, {example, 2, X}} end),
Continuation = rrets_reader:open("my_storage", MatchSpec),
{Records, Continuation1} = rrets_reader:match(Continuation),
...
```After opening a reader a continuation is returned. This continuation can be used to repeatedly
receive lists with matching records. In this case, all tuples matching `{example, 2, _}` terms
are retrieved from the storage. Each matching record is returned with the timestamp when the term
was stored.### Opening a rrets storage ###
RRets storages can be opened by using a name, filename and a specification on how large the
storage files need to become. The name can later be used add terms to the storage.```erlang
Storage = rrets:open([{name, my_storage}, {file, "my_storage"}, {size, {10475520, 10}}]).
```### Storing a term ###
```erlang
Ts = rrets:log(my_storage, {nasi, 3})
````### Closing the storage ###
It is important that the storage is properly closed.
```erlang
rrets:close(my_storage)
````