Quick and dirty permanent key-value storage solution in Ruby using the standard lib (thread safety and locking are done automatically), store any kind of object easily:
http://ruby-doc.org/stdlib/libdoc/yaml/rdoc/YAML/Store.html
http://paste.ubuntu.com/16170480/
def store(key, value = nil)
require "yaml/store"
$y = YAML::Store.new("myfile.yml") if not $y
value ? $y.transaction{ $y[key] = value } : $y.transaction{ return $y[key] }
end
# store anything
value = [1, 2, "hello", {:test => "ok"}]
store "mykey", value
# get it back
value = store "mykey"
# this is the file that is created
$ cat myfile.yml
---
mykey:
- 1
- 2
- hello
- :test: ok