Class: CacheBuilder
- Inherits:
-
Object
- Object
- CacheBuilder
- Defined in:
- lib/libcache/cache_builder.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#build ⇒ Object
Returns the newly created cache.
-
#initialize(cache) ⇒ CacheBuilder
constructor
A new instance of CacheBuilder.
- #set_expiry(time) ⇒ Object
-
#set_max(max_size) ⇒ Object
Sets the optional max size of a cache.
- #set_post_get(proc) ⇒ Object
-
#set_refresh(proc) ⇒ Object
Sets the refresh method required for recalling new objects after expiration.
-
#set_store(path) ⇒ Object
Sets the required file path for the FileCache.
Constructor Details
#initialize(cache) ⇒ CacheBuilder
Returns a new instance of CacheBuilder.
6 7 8 |
# File 'lib/libcache/cache_builder.rb', line 6 def initialize(cache) @cache = cache.new end |
Class Method Details
.with(cache) ⇒ Object
11 12 13 |
# File 'lib/libcache/cache_builder.rb', line 11 def self.with(cache) return self.new(cache) end |
Instance Method Details
#build ⇒ Object
Returns the newly created cache
48 49 50 51 |
# File 'lib/libcache/cache_builder.rb', line 48 def build @cache.create_store return @cache.dup end |
#set_expiry(time) ⇒ Object
23 24 25 26 |
# File 'lib/libcache/cache_builder.rb', line 23 def set_expiry(time) @cache.expiry_time = time return self end |
#set_max(max_size) ⇒ Object
Sets the optional max size of a cache
37 38 39 40 |
# File 'lib/libcache/cache_builder.rb', line 37 def set_max(max_size) @cache.max_size = max_size return self end |
#set_post_get(proc) ⇒ Object
42 43 44 45 |
# File 'lib/libcache/cache_builder.rb', line 42 def set_post_get(proc) @cache.post_get = proc return self end |
#set_refresh(proc) ⇒ Object
Sets the refresh method required for recalling new objects after expiration
30 31 32 33 |
# File 'lib/libcache/cache_builder.rb', line 30 def set_refresh(proc) @cache.refresh = proc return self end |
#set_store(path) ⇒ Object
Sets the required file path for the FileCache
17 18 19 20 |
# File 'lib/libcache/cache_builder.rb', line 17 def set_store(path) @cache.store = path return self end |