Class: Java::NetSfEhcache::CacheManager

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ehcache/cache_manager.rb

Overview

Enhance net.sf.ehcache.CacheManager with a more Rubyesque API.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CacheManager

Enhanced constructor that provides for some extra configuration options. Specifically, String arguments may be used where native Ehcache expects java.io.File objects, and if the String refers to a YAML file it will be used as the Configuration source.



23
24
25
26
27
# File 'lib/ehcache/cache_manager.rb', line 23

def initialize(*args)
  process_init_args(*args) do |*args|
    super(*args)
  end
end

Class Method Details

.create(*args) ⇒ Object

Enhanced create that provides for some extra configuration options. Specifically, String arguments may be used where native Ehcache expects java.io.File objects, and if the String refers to a YAML file it will be used as the Configuration source.



12
13
14
15
16
# File 'lib/ehcache/cache_manager.rb', line 12

def create(*args)
  process_init_args(*args) do |*args|
    ehcache_create(*args)
  end
end

.ehcache_createObject



6
# File 'lib/ehcache/cache_manager.rb', line 6

alias_method :ehcache_create, :create

Instance Method Details

#cache(cache_name = '__default_jruby_cache') ⇒ Object



38
39
40
41
# File 'lib/ehcache/cache_manager.rb', line 38

def cache(cache_name = '__default_jruby_cache')
  self.add_cache_if_absent(cache_name)
  self.get_ehcache(cache_name)
end

#eachObject

Iterate through each cache managed by this CacheManager.



30
31
32
33
34
# File 'lib/ehcache/cache_manager.rb', line 30

def each
  for name in self.cache_names
    yield self.get_ehcache(name)
  end
end

#include?(cache_name) ⇒ Boolean Also known as: exists?

true if cache by given name is being managed, false otherwise

Returns:

  • (Boolean)


44
45
46
# File 'lib/ehcache/cache_manager.rb', line 44

def include?(cache_name)
  self.cache_exists(cache_name)
end