Module: Pione::System::FileCache
- Defined in:
- lib/pione/system/file-cache.rb
Overview
FileCache is a caching system for task workers.
Defined Under Namespace
Classes: FileCacheMethod, NoCacheMethod, SimpleCacheMethod
Class Method Summary collapse
-
.cache_method ⇒ Class
Return file cache class.
-
.cached?(location) ⇒ Boolean
Return true if the location is cached.
-
.clear ⇒ void
Clear cache.
-
.get(location) ⇒ BasicLocation
Get cached data location of the location.
-
.instance ⇒ CacheMethod
Return the singleton.
-
.put(src, location) ⇒ void
Put the data to the location and caches it.
-
.register_file_cache_method(name, klass) ⇒ void
Register the file cache method with the name.
-
.set_cache_method(file_cache_method) ⇒ void
Set a file cache method.
-
.sync(old_location, new_location) ⇒ void
Synchronize cache of old location with new location.
Class Method Details
.cache_method ⇒ Class
Return file cache class.
9 10 11 |
# File 'lib/pione/system/file-cache.rb', line 9 def self.cache_method @klass || SimpleCacheMethod end |
.cached?(location) ⇒ Boolean
Return true if the location is cached.
79 80 81 |
# File 'lib/pione/system/file-cache.rb', line 79 def self.cached?(location) instance.cached?(location) end |
.clear ⇒ void
This method returns an undefined value.
Clear cache.
86 87 88 |
# File 'lib/pione/system/file-cache.rb', line 86 def self.clear instance.clear end |
.get(location) ⇒ BasicLocation
Get cached data location of the location. If the location is not cached and needs to be cached, create the cache and return it. If not, return the location as is.
49 50 51 |
# File 'lib/pione/system/file-cache.rb', line 49 def self.get(location) instance.get(location) end |
.instance ⇒ CacheMethod
Return the singleton.
37 38 39 |
# File 'lib/pione/system/file-cache.rb', line 37 def self.instance @instance ||= cache_method.new end |
.put(src, location) ⇒ void
This method returns an undefined value.
Put the data to the location and caches it.
60 61 62 |
# File 'lib/pione/system/file-cache.rb', line 60 def self.put(src, location) instance.put(src, location) end |
.register_file_cache_method(name, klass) ⇒ void
This method returns an undefined value.
Register the file cache method with the name.
97 98 99 |
# File 'lib/pione/system/file-cache.rb', line 97 def self.register_file_cache_method(name, klass) (@file_cache_method ||= {})[name] = klass end |
.set_cache_method(file_cache_method) ⇒ void
This method returns an undefined value.
Set a file cache method.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pione/system/file-cache.rb', line 18 def self.set_cache_method(file_cache_method) case file_cache_method when Symbol if klass = @file_cache_method[file_cache_method] @klass = klass else raise ArgumentError.new(file_cache_method) end when Class @klass = file_cache_method else raise ArgumentError.new(file_cache_method) end end |
.sync(old_location, new_location) ⇒ void
This method returns an undefined value.
Synchronize cache of old location with new location.
71 72 73 |
# File 'lib/pione/system/file-cache.rb', line 71 def self.sync(old_location, new_location) instance.sync(old_location, new_location) end |