Class: ActiveSupport::Cache::TokyoStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::TokyoStore
- Defined in:
- lib/active_support/cache/tokyo_store.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key, options = nil) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
- #exist?(key, options = nil) ⇒ Boolean
-
#initialize(host = '127.0.0.1', port = 1978) ⇒ TokyoStore
constructor
A new instance of TokyoStore.
- #keys ⇒ Object
- #read(key, options = nil) ⇒ Object
- #write(key, value, options = nil) ⇒ Object
Constructor Details
#initialize(host = '127.0.0.1', port = 1978) ⇒ TokyoStore
Returns a new instance of TokyoStore.
18 19 20 21 22 23 24 25 |
# File 'lib/active_support/cache/tokyo_store.rb', line 18 def initialize(host = '127.0.0.1', port = 1978) super() @data = if Object.const_defined?(:TokyoTyrant) TokyoTyrant::DB.new(host, port) else Rufus::Tokyo::Tyrant.new(host, port) end end |
Instance Method Details
#clear ⇒ Object
56 57 58 59 |
# File 'lib/active_support/cache/tokyo_store.rb', line 56 def clear log("clear", @data.keys.size, nil) @data.clear end |
#delete(key, options = nil) ⇒ Object
41 42 43 44 |
# File 'lib/active_support/cache/tokyo_store.rb', line 41 def delete(key, = nil) super @data.delete(key) end |
#delete_matched(matcher, options = nil) ⇒ Object
46 47 48 49 |
# File 'lib/active_support/cache/tokyo_store.rb', line 46 def delete_matched(matcher, = nil) super @data.keys.each { |k| @data.delete(k) if k =~ matcher } end |
#exist?(key, options = nil) ⇒ Boolean
51 52 53 54 |
# File 'lib/active_support/cache/tokyo_store.rb', line 51 def exist?(key, = nil) super not @data[key].nil? end |
#keys ⇒ Object
61 62 63 |
# File 'lib/active_support/cache/tokyo_store.rb', line 61 def keys @data.keys end |
#read(key, options = nil) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/active_support/cache/tokyo_store.rb', line 27 def read(key, = nil) super @data[key] rescue nil end |
#write(key, value, options = nil) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/active_support/cache/tokyo_store.rb', line 34 def write(key, value, = nil) super @data[key] = value rescue nil end |