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, SimpleCacheMethod

Class Method Summary collapse

Class Method Details

.cache_methodClass

Return file cache class.

Returns:

  • (Class)

    CacheMethod 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.

Returns:

  • (Boolean)

    true if the location is cached



66
67
68
# File 'lib/pione/system/file-cache.rb', line 66

def self.cached?(location)
  instance.cached?(location)
end

.clearvoid

This method returns an undefined value.

Clear cache.



73
74
75
# File 'lib/pione/system/file-cache.rb', line 73

def self.clear
  instance.clear
end

.get(location) ⇒ Pathname

Get cached data path from the uri resource.

Parameters:

  • location (BasicLocation)

    data location

Returns:

  • (Pathname)

    cached path



36
37
38
# File 'lib/pione/system/file-cache.rb', line 36

def self.get(location)
  instance.get(location)
end

.instanceCacheMethod

Return the singleton.

Returns:

  • (CacheMethod)

    cache method instance



26
27
28
# File 'lib/pione/system/file-cache.rb', line 26

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.

Parameters:

  • src (String)

    source path

  • location (BasicLocation)

    destination location



47
48
49
# File 'lib/pione/system/file-cache.rb', line 47

def self.put(src, location)
  instance.put(src, location)
end

.set_cache_method(klass) ⇒ void

This method returns an undefined value.

Set a file cache class.

Parameters:

  • klass (Class)

    CacheMethod class



18
19
20
# File 'lib/pione/system/file-cache.rb', line 18

def self.set_cache_method(klass)
  @klass = klass
end

.sync(old_location, new_location) ⇒ void

This method returns an undefined value.

Synchronize cache of old location with new location.

Parameters:

  • old_location (BasicLocation)

    old data location

  • new_location (BasicLocation)

    new data location



58
59
60
# File 'lib/pione/system/file-cache.rb', line 58

def self.sync(old_location, new_location)
  instance.sync(old_location, new_location)
end