Class: MapRedus::FileSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/mapredus/filesystem.rb

Overview

Manages the book keeping of redis keys and redis usage provides the data storage for process information through redis All interaction with redis should go through this class

Class Method Summary collapse

Class Method Details

.acquire_lock(key) ⇒ Object



35
36
37
# File 'lib/mapredus/filesystem.rb', line 35

def self.acquire_lock(key)
  MapRedus.acquire_redis_lock_nonblock( RedisKey.result_cache(key), 60 * 60 )
end

.has_lock?(key) ⇒ Boolean

Setup locks on results using RedisSupport lock functionality

Examples

FileSystem::has_lock?(key)
# => true or false

Returns true if there’s a lock

Returns:

  • (Boolean)


31
32
33
# File 'lib/mapredus/filesystem.rb', line 31

def self.has_lock?(key)
  MapRedus.has_redis_lock?( RedisKey.result_cache(key) ) 
end

.method_missing(method, *args, &block) ⇒ Object



20
21
22
# File 'lib/mapredus/filesystem.rb', line 20

def self.method_missing(method, *args, &block)
  storage.send(method, *args)
end

.release_lock(key) ⇒ Object



39
40
41
# File 'lib/mapredus/filesystem.rb', line 39

def self.release_lock(key)
  MapRedus.release_redis_lock( RedisKey.result_cache(key) )
end

.save(key, value, time = nil) ⇒ Object

Save/Read functions to save/read values for a redis key

Examples

FileSystem.save( key, value )


15
16
17
18
# File 'lib/mapredus/filesystem.rb', line 15

def self.save(key, value, time = nil)
  storage.set(key, value)
  storage.expire(key, time) if time
end

.storageObject



7
8
9
# File 'lib/mapredus/filesystem.rb', line 7

def self.storage
  MapRedus.redis
end