On May 17, 2007, at 12:48 AM, Bill Kelly wrote:

> Hi,
>
> Essentially I'm looking for something that acts like a ruby Hash,
> is nearly as fast as a ruby Hash, but is persistent.  It should
> also be able to remember gigabytes of information on disk, while
> not using a ton of resident RAM in the process.
>
> Also, when I restart the ruby process, the overhead when
> initially "connecting to or opening" this persistent hash should
> be very minimal before I can start using it.
>
> Does such a beast exist?
>
> From what I've read, it seems like the Berkeley DB might fit the
> bill; although I'm a little worried I couldn't find the cost of
> a commercial license listed anywhere on the website.
>
> Are there other options besides BDB?
>
>
> Thanks,
>
> Regards,
>
> Bill
>
>
>

cfp:~ > cat a.rb
require 'yaml'
require 'time'

### *nix AND windblows.  built-in to ruby
DB =
   begin
     require 'sdbm'
     SDBM
   rescue LoadError
     require 'dbm'
     DBM
   end

db = DB.new 'db'

last_time = db['last_time']
this_time = Time.now.iso8601(2)

y 'last_time' => last_time, 'this_time' => this_time

db['last_time'] = this_time
cfp:~ > ruby a.rb
---
this_time: "2007-05-17T13:56:13.97-06:00"
last_time:
cfp:~ > ruby a.rb
---
this_time: "2007-05-17T13:56:15.59-06:00"
last_time: "2007-05-17T13:56:13.97-06:00"
cfp:~ > ruby a.rb
---
this_time: "2007-05-17T13:56:16.91-06:00"
last_time: "2007-05-17T13:56:15.59-06:00"


-a
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama