https://github.com/squaremo/jsonspace
A tuple space but with JSON
https://github.com/squaremo/jsonspace
Last synced: about 2 months ago
JSON representation
A tuple space but with JSON
- Host: GitHub
- URL: https://github.com/squaremo/jsonspace
- Owner: squaremo
- Created: 2011-09-27T20:32:47.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-06-07T23:06:27.000Z (about 14 years ago)
- Last Synced: 2025-01-25T05:41:16.524Z (over 1 year ago)
- Language: Erlang
- Homepage:
- Size: 96.7 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## So far ...
$ rebar get-deps
$ rebar compile
$ erl -pa deps/rejson/ebin ebin
1> {ok, S} = jsonspc_query:start_link().
{ok, <0.33.0>}
2> {ok, E} = rejson:parse("foo = [1, 2, number *]").
{ok,{capture,"foo",[1,2,{star,number}]}}
3> f(Ref), Ref = jsonspc_query:read(S, E, self()).
#Ref<0.0.0.35>
4> f(R), receive {result, R, Ref} -> R after 100 -> no end.
no
5> jsonspc_query:write(S, [1, 2, 3, 4]).
ok
6> f(R), receive {result, R, Ref} -> R after 100 -> no end.
[{"foo",[1,2,3,4]}]
## What?
This is an experiment in writing a database with tuplespace-like
semantics, using rejson pattern matching (which is described [over
here](https://github.com/squaremo/rejson#readme)).
There are three operations:
* `write(Value)`
* `read(Expression)`
* `take(Expression)`
`read` and `take` return the result of successfully matching the given
expression with a value from those values that have been, or will be,
supplied with `write`. `take` removes the value from the database;
`read` leaves it there. Successive calls to `read` may not return the
same value -- the choice is non-deterministic.