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

Returns file cache class.

Returns:

  • (Class)

    CacheMethod class



8
9
10
# File 'lib/pione/system/file-cache.rb', line 8

def self.cache_method
  @klass || SimpleCacheMethod
end

.get(uri) ⇒ String

Gets cached data path from the uri resource.

Parameters:

Returns:

  • (String)

    cached path string



32
33
34
# File 'lib/pione/system/file-cache.rb', line 32

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

.instanceCacheMethod

Returns the singleton.

Returns:

  • (CacheMethod)

    cache method instance



23
24
25
# File 'lib/pione/system/file-cache.rb', line 23

def self.instance
  @instance ||= cache_method.new
end

.put(src, uri) ⇒ Object

Puts the data to uri resource and caches it.



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

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

.set_cache_method(klass) ⇒ void

This method returns an undefined value.

Sets a file cache class.

Parameters:

  • klass (Class)

    CacheMethod class



16
17
18
# File 'lib/pione/system/file-cache.rb', line 16

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

.shift(old_uri, new_uri) ⇒ void

This method returns an undefined value.

Shifts the resource from old uri to new uri.

Parameters:

  • old_uri (String)

    old resource uri

  • new_uri (String)

    new resource uri



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

def self.shift(old_uri, new_uri)
  instance.shift(old_uri, new_uri)
end