Class: ActiveSupport::Cache::JcacheStore

Inherits:
Store
  • Object
show all
Defined in:
lib/jcache_store.rb,
lib/active_support/cache/jcache_store.rb

Defined Under Namespace

Classes: JcacheError

Constant Summary collapse

VERSION =
'0.1.0'

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ JcacheStore

Returns a new instance of JcacheStore.



13
14
15
16
# File 'lib/active_support/cache/jcache_store.rb', line 13

def initialize(options = {})
  cacheFactory = CacheManager.get_instance.get_cache_factory;
  @data = cacheFactory.create_cache(Collections.empty_map);
end

Instance Method Details

#clearObject



56
57
58
59
60
61
62
# File 'lib/active_support/cache/jcache_store.rb', line 56

def clear
  @data.clear
  true
rescue CacheException => e
  logger.error("JcacheError (#{e}): #{e.message}")
  false
end

#delete(key, options = nil) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/active_support/cache/jcache_store.rb', line 35

def delete(key, options = nil)
  super
  @data.remove(key)
rescue CacheException => e
  logger.error("JcacheError (#{e}): #{e.message}")
  false
end

#delete_matched(matcher, options = nil) ⇒ Object



51
52
53
54
# File 'lib/active_support/cache/jcache_store.rb', line 51

def delete_matched(matcher, options = nil)
  super
  raise "Not supported by Ehcache"
end

#exist?(key, options = nil) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_support/cache/jcache_store.rb', line 47

def exist?(key, options = nil)
  @data.contains_key(key)
end

#keysObject



43
44
45
# File 'lib/active_support/cache/jcache_store.rb', line 43

def keys
  @data.key_set.to_a
end

#read(key, options = nil) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/active_support/cache/jcache_store.rb', line 18

def read(key, options = nil)
  super
  @data.get(key)
rescue CacheException => e
  logger.error("JcacheError (#{e}): #{e.message}")
  false
end

#write(key, value, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/active_support/cache/jcache_store.rb', line 26

def write(key, value, options = {})
  super
  @data.put(key, value)
  true
rescue CacheException => e
  logger.error("JcacheError (#{e}): #{e.message}")
  false
end