Class: UzuUzu::Memcache::Leveldb
- Defined in:
- lib/uzuuzu-core/memcache/leveldb.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #get(key) ⇒ Object (also: #[])
-
#initialize(env = nil) ⇒ Leveldb
constructor
A new instance of Leveldb.
- #method_missing(action, *args) ⇒ Object
- #put(key, value) ⇒ Object (also: #[]=)
Constructor Details
#initialize(env = nil) ⇒ Leveldb
Returns a new instance of Leveldb.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/uzuuzu-core/memcache/leveldb.rb', line 13 def initialize(env=nil) @adapter = :leveldb address = 'cache' space = 'leveldb' if env address = env['address'] || address space = env['space'] || UzuUzu.application.name || space end unless ::File.exists?(address) ::FileUtils.mkdir_p(address) end @db = LevelDB::DB.new("#{address}/#{space}") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(action, *args) ⇒ Object
41 42 43 |
# File 'lib/uzuuzu-core/memcache/leveldb.rb', line 41 def method_missing(action, *args) @db.send(action, *args) end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/uzuuzu-core/memcache/leveldb.rb', line 8 def adapter @adapter end |
Instance Method Details
#get(key) ⇒ Object Also known as: []
28 29 30 |
# File 'lib/uzuuzu-core/memcache/leveldb.rb', line 28 def get(key) @db.get(key.to_s) end |
#put(key, value) ⇒ Object Also known as: []=
33 34 35 |
# File 'lib/uzuuzu-core/memcache/leveldb.rb', line 33 def put(key, value) @db.put(key.to_s, value) end |