bucket_cache_hook
This is a sample post commit hook for Riak that generates an aggregate JSON representation of the contents of a bucket.
Installation
The easiest way to install the bucket_cache_hook is to copy it into the root directory of your riak installation and:
# start riak and compile the bucket_cache_hook.erl
$ ./bin/riak console
([email protected])1> c(bucket_cache_hook).
([email protected])2> q().
# then add it as a postcommit hook to your chosen bucket
$ curl -XPUT -H "Content-Type: application/json" http://localhost:8091/riak/test -d '{"props":{"postcommit":[{"mod": "bucket_cache_hook", "fun": "create_cache"}]}}'
# now load a test payload
$ curl -XPUT -H "Content-Type: applicaiton/json" http://localhost:8091/riak/test/test.json -d '{ "message": "this is a test" }'
# then check that it loaded
$ curl http://localhost:8091/riak/test/test.json
{ "message": "this is a test" }
# next check the cache, you'll find [ {filename : payload } ]
$ curl http://localhost:8091/riak/cache/test
[{"test.json":{"message":"this is a test"}}]
# then clean up after yourself
$ curl -XDELETE http://localhost:8091/riak/test/test.json
$ curl http://localhost:8091/riak/cache/test
[]
David J. Goehrig