Class: ActiveSupport::Cache::TorqueBoxStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::TorqueBoxStore
- Defined in:
- lib/active_support/cache/torque_box_store.rb
Constant Summary collapse
- SECONDS =
java.util.concurrent.TimeUnit::SECONDS
Instance Method Summary collapse
-
#cleanup(options = nil) ⇒ Object
Cleanup the cache by removing expired entries.
-
#clear(options = nil) ⇒ Object
Clear the entire cache.
- #clustering_mode ⇒ Object
-
#decrement(name, amount = 1, options = nil) ⇒ Object
Decrement an integer value in the cache; return new value.
-
#delete_matched(matcher, options = nil) ⇒ Object
Delete all entries with keys matching the pattern.
-
#increment(name, amount = 1, options = nil) ⇒ Object
Increment an integer value in the cache; return new value.
-
#initialize(options = {}) ⇒ TorqueBoxStore
constructor
A new instance of TorqueBoxStore.
- #name ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TorqueBoxStore
Returns a new instance of TorqueBoxStore.
30 31 32 33 |
# File 'lib/active_support/cache/torque_box_store.rb', line 30 def initialize( = {}) super() cache end |
Instance Method Details
#cleanup(options = nil) ⇒ Object
Cleanup the cache by removing expired entries.
79 80 81 82 83 84 85 |
# File 'lib/active_support/cache/torque_box_store.rb', line 79 def cleanup( = nil) = () keys.each do |key| entry = read_entry(key, ) delete_entry(key, ) if entry && entry.expired? end end |
#clear(options = nil) ⇒ Object
Clear the entire cache. Be careful with this method since it could affect other processes if shared cache is being used.
45 46 47 |
# File 'lib/active_support/cache/torque_box_store.rb', line 45 def clear( = nil) cache.clear end |
#clustering_mode ⇒ Object
39 40 41 |
# File 'lib/active_support/cache/torque_box_store.rb', line 39 def clustering_mode cache.clustering_mode end |
#decrement(name, amount = 1, options = nil) ⇒ Object
Decrement an integer value in the cache; return new value
74 75 76 |
# File 'lib/active_support/cache/torque_box_store.rb', line 74 def decrement(name, amount = 1, = nil) increment( name, -amount, ) end |
#delete_matched(matcher, options = nil) ⇒ Object
Delete all entries with keys matching the pattern.
50 51 52 53 54 |
# File 'lib/active_support/cache/torque_box_store.rb', line 50 def delete_matched( matcher, = nil ) = () pattern = key_matcher( matcher, ) keys.each { |key| delete( key, ) if key =~ pattern } end |
#increment(name, amount = 1, options = nil) ⇒ Object
Increment an integer value in the cache; return new value
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_support/cache/torque_box_store.rb', line 57 def increment(name, amount = 1, = nil) = ( ) # Get the current entry key = namespaced_key( name, ) current = read_entry(key, ) value = current.value.to_i new_entry = Entry.new( value+amount, ) if cache.replace(key, current, new_entry) return new_entry.value else raise "Concurrent modification, old value was #{value}" end end |
#name ⇒ Object
35 36 37 |
# File 'lib/active_support/cache/torque_box_store.rb', line 35 def name [:name] || TORQUEBOX_APP_NAME end |