Class: Waves::Caches::Synchronized

Inherits:
Object
  • Object
show all
Defined in:
lib/waves/caches/synchronized.rb

Overview

This is just a proxy for the real cache, but adds Waves synchronization. Pass the cache you want to use when you create the cache.

Instance Method Summary collapse

Constructor Details

#initialize(cache) ⇒ Synchronized

Returns a new instance of Synchronized.



13
# File 'lib/waves/caches/synchronized.rb', line 13

def initialize( cache ) ; @cache = cache ; end

Instance Method Details

#[](key) ⇒ Object



14
# File 'lib/waves/caches/synchronized.rb', line 14

def [](key) ; @cache.fetch(key) ; end

#[]=(key, value) ⇒ Object



15
# File 'lib/waves/caches/synchronized.rb', line 15

def []=( key, value ) ; @cache.store( key, value ) ; end

#clearObject



21
# File 'lib/waves/caches/synchronized.rb', line 21

def clear ; synchronize { @cache.clear } ; end

#delete(key) ⇒ Object



20
# File 'lib/waves/caches/synchronized.rb', line 20

def delete( key ) ; synchronize { @cache.delete( key ) } ; end

#exists?(key) ⇒ Boolean Also known as: exist?

Returns:

  • (Boolean)


16
# File 'lib/waves/caches/synchronized.rb', line 16

def exists?( key ) ; @cache.has_key?( key ) ; end

#fetch(keys) ⇒ Object



19
# File 'lib/waves/caches/synchronized.rb', line 19

def fetch( keys ) ; @cache.fetch( key ) ; end

#store(key, val) ⇒ Object



18
# File 'lib/waves/caches/synchronized.rb', line 18

def store( key, val ) ; synchronize { @cache.store( key, value ) }; end

#synchronize(&block) ⇒ Object



22
# File 'lib/waves/caches/synchronized.rb', line 22

def synchronize( &block ) ; Waves.synchronize( &block ) ; end