Class: DistributedTrie::KvsIf
- Inherits:
-
Object
- Object
- DistributedTrie::KvsIf
- Defined in:
- lib/distributedtrie/kvsif.rb
Overview
Example of Key-Value Store Interface Please implement your version like this.
Direct Known Subclasses
Instance Method Summary collapse
- #_getInternal ⇒ Object
- #delete(key) ⇒ Object
- #get(key, fallback = false) ⇒ Object
-
#initialize ⇒ KvsIf
constructor
A new instance of KvsIf.
- #put!(key, value, timeout = 0) ⇒ Object
Constructor Details
#initialize ⇒ KvsIf
Returns a new instance of KvsIf.
40 41 42 |
# File 'lib/distributedtrie/kvsif.rb', line 40 def initialize() @data = Hash.new end |
Instance Method Details
#_getInternal ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/distributedtrie/kvsif.rb', line 60 def _getInternal( ) arr = [] @data.keys.each { |key| arr << [key,@data[key]] } arr end |
#delete(key) ⇒ Object
57 58 |
# File 'lib/distributedtrie/kvsif.rb', line 57 def delete( key ) end |
#get(key, fallback = false) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/distributedtrie/kvsif.rb', line 48 def get( key, fallback = false ) val = @data[key] if val val else fallback end end |
#put!(key, value, timeout = 0) ⇒ Object
44 45 46 |
# File 'lib/distributedtrie/kvsif.rb', line 44 def put!( key, value, timeout = 0 ) @data[key] = value end |