mruby binding of yahoojapan/k2hash
- build mruby with mruby-k2hash. Or use the Docker image.
# mruby root dir
$ MRUBY_CONFIG=./path/to/build_config.rb ./minirake
- Run mirb and test K2Hash class
$ ./build/host/bin/mirb
mirb - Embeddable Interactive Ruby Shell
>
>
> k2hash = K2Hash.new('/tmp/tmp.k2hash', 0666, K2Hash::WRCREAT)
=> #<K2Hash:0x127ada0>
> k2hash.store('key', 'value')
=> nil
> k2hash.fetch('key')
=> "value"
> k2hash.store('key', 'new value')
=> nil
> k2hash.fetch('key')
=> "new value"
> k2hash['key2'] = 'value2'
=> "value2"
> k2hash['key2']
=> "value2"
> k2hash.close
=> nil
-
DBM like methods:
H2Hashhaseachso you can also use Enumerable methods.
| method | implemented? |
|---|---|
| [] | ✔️ |
| []= | ✔️ |
| clear | ✔️ |
| close | ✔️ |
| closed? | ✔️ |
| delete | ✔️ |
| delete_if | ✔️ |
| reject! | ✔️ |
| each | ✔️ |
| each_pair | ✔️ |
| each_key | ✔️ |
| each_value | ✔️ |
| empty? | ✔️ |
| fetch | ✔️ |
| has_key? | ✔️ |
| include? | ✔️ |
| key? | ✔️ |
| member? | ✔️ |
| has_value? | ✔️ |
| value? | ✔️ |
| invert | ✔️ |
| key | ✔️ |
| keys | ✔️ |
| length | ✔️ |
| size | ✔️ |
| reject | ✔️ |
| replace | ✔️ |
| select | ✔️ |
| shift | ✔️ |
| store | ✔️ |
| to_a | ✔️ |
| to_hash | ✔️ |
| update | ✔️ |
| values | ✔️ |
| values_at | ✔️ |
-
subkey
fetch_subkeys(key) -> Arrayreturns subkey array corresponding to the key strstore_subkeys(key, subkeys) -> selfset the subkey array to the key str
-
Support k2hash features. Especially...:
- open mode
- transaction
- queue
- attributes
MITL