class Trocla::Store
implements the default store behavior
Attributes
Public Class Methods
# File lib/trocla/store.rb, line 4 def initialize(config,trocla) @store_config = config @trocla = trocla end
Public Instance Methods
closes the store when called do whatever “closes” your store, e.g. close database connections.
# File lib/trocla/store.rb, line 12 def close end
deletes the value for format if format is nil everything is deleted returns value of format or hash of format => value # if everything is deleted.
# File lib/trocla/store.rb, line 49 def delete(key,format=nil) format.nil? ? (delete_all(key)||{}) : delete_format(key,format) end
should return value for key & format returns nil if nothing or a nil value was found. If a key is expired it must return nil.
# File lib/trocla/store.rb, line 19 def get(key,format) raise 'not implemented' end
sets value for key & format setting the plain format must invalidate all other formats as they should either be derived from plain or set directly. options is a hash containing further information for the store. e.g. expiration of a key. Keys can have an expiration / timeout by setting `expires` within the options hashs. Value of `expires` must be an integer indicating the amount of seconds a key can live with. This mechanism is expected to be be implemented by the backend.
# File lib/trocla/store.rb, line 36 def set(key,format,value,options={}) if format == 'plain' set_plain(key,value,options) else set_format(key,format,value,options) end end
Private Instance Methods
deletes all entries of this key and returns a hash with all formats and values or nil if nothing is found
# File lib/trocla/store.rb, line 70 def delete_all(key) raise 'not implemented' end
deletes the value of the passed key & format and returns the value.
# File lib/trocla/store.rb, line 77 def delete_format(key,format) raise 'not implemented' end
sets a value of a format
# File lib/trocla/store.rb, line 62 def set_format(key,format,value,options) raise 'not implemented' end
sets a new plain value must invalidate all other formats
# File lib/trocla/store.rb, line 57 def set_plain(key,value,options) raise 'not implemented' end