Skip to content

This is a sample post commit hook for Riak that generates an aggregate JSON representation of the contents of a bucket.

Notifications You must be signed in to change notification settings

willCode2Surf/bucket_cache_hook

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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
(riak1@127.0.0.1)1> c(bucket_cache_hook).
(riak1@127.0.0.1)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

About

This is a sample post commit hook for Riak that generates an aggregate JSON representation of the contents of a bucket.

Resources

Stars

Watchers

Forks

Packages

No packages published