public
Created

basic read write cache for riak

  • Download Gist
riak_cache.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
require 'riak'
 
class RiakCache
 
def initialize
@client = Riak::Client.new(:pb_port => 8081, :protocol => :pbc)
@bucket = @client.bucket("riakcache")
end
 
def read(key)
@object = @bucket.get(key)
@object.data
end
 
def write(key, value)
@object = @bucket.get_or_new(key)
@object.content_type = 'application/x-ruby-marshal'
@object.data = value
@object.store
end
 
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.