class Trocla::Store

implements the default store behavior

Attributes

store_config[R]
trocla[R]

Public Class Methods

new(config,trocla) click to toggle source
# File lib/trocla/store.rb, line 4
def initialize(config,trocla)
  @store_config = config
  @trocla = trocla
end

Public Instance Methods

close() click to toggle source

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
delete(key,format=nil) click to toggle source

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
get(key,format) click to toggle source

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
set(key,format,value,options={}) click to toggle source

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

delete_all(key) click to toggle source

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
delete_format(key,format) click to toggle source

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
set_format(key,format,value,options) click to toggle source

sets a value of a format

# File lib/trocla/store.rb, line 62
def set_format(key,format,value,options)
  raise 'not implemented'
end
set_plain(key,value,options) click to toggle source

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