kvstore is a key value store implemented as a wrapper around Mnesia. Its distinctive feature is tracking access times.
kvstore uses Mnesia to store data. It defines the following fields:
- key
- time_created
- time_modified
- time_accessed
- value
Access times are tracked in time_accessed field.
The obvious preprequisite for kvstore is the Erlang runtime. To install:
-
clone this project and cd into its directory
-
compile
`erl -make`
-
to install with 2 nodes called kv1 and kv2 start Erlang shell in 2 different shells
`shell1> erl -pa ebin/ -sname kv1@localhost` `shell2> erl -pa ebin/ -sname kv2@localhost`
-
link kv2 to kv1 - i.e. in kv2 shell type
`net_kernel:connect_node('kv1@localhost').`
-
install on all linked nodes - from either node run
`kvstore:install_all_nodes().`
-
installation is now complete
To run tests, change into the project directory and run:
ct_run -pa ebin/ -spec kvstore.spec
To run the kvstore server:
-
start the Erlang shell on each host or Mnesia instance
`shell1> erl -pa ebin/ -sname kv1@localhost` `shell2> erl -pa ebin/ -sname kv2@localhost`
-
connect each instance - i.e. on all instances except the first:
`net_kernel:connect_node('kv1@localhost').`
-
start applications on all instances:
`application:start(mnesia).` `application:start(kvstore).`
After starting the server as above, you can run commands from shell to operate on the data:
-
to write data
`kvstore:write("key-1", "value-1").`
-
to read data by key
`kvstore:read("key-1").`
-
to delete data by key
`kvstore:delete("key-1").`
Coming soon...