module Pione::System::FileCache

FileCache is a caching system for task workers.

Public Class Methods

cache_method() click to toggle source

Return file cache class.

@return [Class]

CacheMethod class
# File lib/pione/system/file-cache.rb, line 9
def self.cache_method
  @klass || SimpleCacheMethod
end
cached?(location) click to toggle source

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() click to toggle source

Clear cache.

@return [void]

# File lib/pione/system/file-cache.rb, line 86
def self.clear
  instance.clear
end
get(location) click to toggle source

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
instance() click to toggle source

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(src, location) click to toggle source

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_file_cache_method(name, klass) click to toggle source

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_cache_method(file_cache_method) click to toggle source

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
sync(old_location, new_location) click to toggle source

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