Class: Lawnchair::StorageEngine::InProcess

Inherits:
Abstract
  • Object
show all
Defined in:
lib/storage_engine/in_process.rb

Constant Summary collapse

@@data_store =
{}

Class Method Summary collapse

Methods inherited from Abstract

computed_key, db_connection?, fetch, get, log

Class Method Details

.data_storeObject



7
8
9
# File 'lib/storage_engine/in_process.rb', line 7

def data_store
  @@data_store
end

.exists?(key) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/storage_engine/in_process.rb', line 19

def exists?(key)
  data_store.has_key?(computed_key(key))
end

.expire!(key) ⇒ Object



23
24
25
26
27
# File 'lib/storage_engine/in_process.rb', line 23

def expire!(key)
  start_time = Time.now
  data_store.delete(computed_key(key))
  log("EXPIRATION", key, Time.now-start_time)
end

.set(key, value, options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/storage_engine/in_process.rb', line 11

def set(key, value, options={})
  if options[:raw]
    data_store[computed_key(key)] = value
  else
    data_store[computed_key(key)] = Marshal.dump(value)
  end
end