viodotcom / process_store

A library which allows to store temporary data in the process dictionary.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Process Store

Hex.pm Docs Build Status License

A simple library to store and retrieve data from the process tree.

Installation

The package is available in Hex, and can be installed by adding process_store to your list of dependencies in mix.exs:

def deps do
  [
    {:process_store, "~> 0.2.0"}
  ]
end

Usage

Store a value:

iex> ProcessStore.store(:my_key, "my value")
nil

# When a key already exists, store the new value and return the previous one.
iex> ProcessStore.store(:my_key, "a new value")
"my value"

Fetch a value:

iex> ProcessStore.fetch(:my_key)
"a new value"

iex> ProcessStore.store(:non_existing_key)
nil

The stored values are available in different processes:

iex> ProcessStore.store(:my_key, "my value")
nil

iex> task = Task.async(fn -> ProcessStore.fetch(:my_key) end)
%Task{
  owner: #PID<0.184.0>,
  pid: #PID<0.208.0>,
  ref: #Reference<0.1292195905.2439512066.24239>
}

iex> Task.await(task)
"my value"

Full documentation

The full documentation is available at https://hexdocs.pm/process_store.

Development

Helpful make commands are available for development, like to install dependencies and run tests.

To list all the make commands:

make

Release

After merge a new feature/bug you can bump and publish it with:

make release
make publish

Contributing

See the contributing guide.

License

Process Store is released under the Apache 2.0 License. See the LICENSE file.

Author

FindHotel

FindHotel

About

A library which allows to store temporary data in the process dictionary.

License:Apache License 2.0


Languages

Language:Elixir 72.2%Language:Makefile 27.8%