https://github.com/iboard/bucketier
A simple Elixir Dictionary Application
https://github.com/iboard/bucketier
dictionary-application elixir elixir-lang hex
Last synced: 11 months ago
JSON representation
A simple Elixir Dictionary Application
- Host: GitHub
- URL: https://github.com/iboard/bucketier
- Owner: iboard
- License: mit
- Created: 2018-07-21T11:23:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-04T12:38:30.000Z (over 7 years ago)
- Last Synced: 2025-04-04T08:08:48.202Z (about 1 year ago)
- Topics: dictionary-application, elixir, elixir-lang, hex
- Language: Elixir
- Homepage: https://hex.pm/packages/bucktier
- Size: 212 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Bucketier README
[](http://hexdocs.pm/bucketier/)
[](https://travis-ci.com/iboard/bucketier)
**Bucketier** is a simple _Dictionary_ application you can use to store
data in a simple _Bucket_ (Key/Value store).
See `Bucketier.Bucket` for more information.
## Installation
Bucketier is [available as hex package](https://hex.pm/packages/bucketier),
the package can be installed by adding `bucketier` to your list of dependencies
in `mix.exs` and optionally start it with your application:
```elixir
def application do
[
applications: [:bucketier], ### add :bucketier here
extra_applications: [:logger],
mod: {YourElixirApp.Application, []}
]
end
def deps do
[
{:bucketier, "~> 0.1"}
]
end
```
Documentation can be found at [https://hexdocs.pm/bucketier](https://hexdocs.pm/bucketier).
## Examples
The best way to figure out how you can use this library is by having a look at
this [Test suite](https://github.com/iboard/hexpack-examples/blob/master/test/hexpack_examples_test.exs).
### Put some items in a shopping list and retreive the bucket by name
```elixir
alias Bucketier.Bucket
Bucket.bucket("shopping list")
|> Bucket.put( 1, "Milk")
|> Bucket.put( 2, "Butter")
|> Bucket.put( 3, "Bread")
|> Bucket.commit
Bucket.bucket("shopping list")
#=> %Bucketier.Bucket{
#=> data: %{ 1 => "Milk", 2 => "Butter", 3 => "Bread"},
#=> name: "shopping list"
#=> }
```
`Bucket.bucket("bucket name")` will return a struct of type `%Bucket{}`.
`Bucket.put` will add keys to this structure but will not save the new
state to the `Bucketier` until you call `Bucket.commit(mybucket)`.
### Put some items in a list and retreive values by keys later
```elixir
alias Bucketier.Bucket
Bucket.bucket("shopping list")
|> Bucket.put( 1, "Milk")
|> Bucket.put( 2, "Butter")
|> Bucket.put( 3, "Bread")
|> Bucket.commit
Bucket.get("shopping list", 2)
#=> "Butter"
Bucket.keys("shopping list")
#=> [1,2,3]
Bucket.values("shopping list")
#=> ["Milk, "Butter", "Bread"]
```
## Roadmap
The project is a sidekick from a project at our company and will hopefully
mature over the next weeks.
Obviously, updating and deleting of entries, real persistence (on disc),
and other features are missing and will follow.