module Pione::System::FileCache
FileCache
is a caching system for task workers.
Public Class Methods
Return file cache class.
@return [Class]
CacheMethod class
# File lib/pione/system/file-cache.rb, line 9 def self.cache_method @klass || SimpleCacheMethod end
Return true if the location is cached.
@return [Boolean]
true if the location is cached
# File lib/pione/system/file-cache.rb, line 79 def self.cached?(location) instance.cached?(location) end
Clear cache.
@return [void]
# File lib/pione/system/file-cache.rb, line 86 def self.clear instance.clear end
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.
@param location [BasicLocation]
data location
@return [BasicLocation]
cached location
# File lib/pione/system/file-cache.rb, line 49 def self.get(location) instance.get(location) end
Return the singleton.
@return [CacheMethod]
cache method instance
# File lib/pione/system/file-cache.rb, line 37 def self.instance @instance ||= cache_method.new end
Put the data to the location and caches it.
@param src [String]
source path
@param location [BasicLocation]
destination location
@return [void]
# File lib/pione/system/file-cache.rb, line 60 def self.put(src, location) instance.put(src, location) end
Register the file cache method with the name.
@param name [Symbol]
the name of file cache method
@param klass [FileCacheMethod]
file cache method class
@return [void]
# File lib/pione/system/file-cache.rb, line 97 def self.register_file_cache_method(name, klass) (@file_cache_method ||= {})[name] = klass end
Set a file cache method.
@param klass [Class]
CacheMethod class
@return [void]
# 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
Synchronize cache of old location with new location.
@param old_location [BasicLocation]
old data location
@param new_location [BasicLocation]
new data location
@return [void]
# File lib/pione/system/file-cache.rb, line 71 def self.sync(old_location, new_location) instance.sync(old_location, new_location) end