class Moneta::Adapters::Riak
Riak
backend @api public @author Potapov Sergey (aka Blake)
Public Class Methods
new(options = {})
click to toggle source
@param [Hash] options @option options [String] :bucket (‘moneta’) Bucket name @option options [String] :content_type (‘application/octet-stream’) Default content type @option options [::Riak::Client] :backend Use existing backend instance @option options All other options passed to ‘Riak::Client#new`
Calls superclass method
Moneta::Adapter::new
# File lib/moneta/adapters/riak.rb, line 19 def initialize(options = {}) super @bucket = backend.bucket(config.bucket) end
Public Instance Methods
clear(options = {})
click to toggle source
(see Proxy#clear
)
# File lib/moneta/adapters/riak.rb, line 53 def clear(options = {}) @bucket.keys do |keys| keys.each { |key| @bucket.delete(key) } end self end
delete(key, options = {})
click to toggle source
(see Proxy#delete
)
# File lib/moneta/adapters/riak.rb, line 37 def delete(key, options = {}) value = load(key, options) @bucket.delete(key, options.dup) value end
key?(key, options = {})
click to toggle source
(see Proxy#key?
)
# File lib/moneta/adapters/riak.rb, line 25 def key?(key, options = {}) @bucket.exists?(key, options.dup) end
load(key, options = {})
click to toggle source
(see Proxy#load
)
# File lib/moneta/adapters/riak.rb, line 30 def load(key, options = {}) @bucket.get(key, options.dup).raw_data rescue ::Riak::FailedRequest nil end
store(key, value, options = {})
click to toggle source
(see Proxy#store
)
# File lib/moneta/adapters/riak.rb, line 44 def store(key, value, options = {}) obj = ::Riak::RObject.new(@bucket, key) obj.content_type = options[:content_type] || config.content_type obj.raw_data = value obj.store(options.dup) value end