--8323328-832260909-10957075268837 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-832260909-1095707526=:18837" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-832260909-10957075268837 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Mon, 20 Sep 2004, [ISO-8859-1] Kristian Søòensen wrote: > Hi! > > Is there some way of writing e.g. a hash table to the filesystem, and read > it again? - Without having to parse in and output (and create the table all > over). > > I need to store some information, which could be storred in a small database > (like sqlite - but I can't get ruby-sqlite installed proporly, if sqlite is > not installed in the default location). Is there an interface to the Berkley > DB (www.sleepycat.com)? > > > Best regards, > Kristian Søòensen. yes. yes. jib:~ > cat a.rb require 'pstore' db = PStore::new 'db' this_time = Time::now last_time = nil db.transaction do if db.root? 'time' last_time = db['time'] end db['time'] = this_time end puts "this_time <#{ this_time }>" puts "last_time <#{ last_time }>" jib:~ > ruby a.rb this_time <Mon Sep 20 13:05:29 MDT 2004> last_time <> jib:~ > ruby a.rb this_time <Mon Sep 20 13:05:33 MDT 2004> last_time <Mon Sep 20 13:05:29 MDT 2004> jib:~ > ruby a.rb this_time <Mon Sep 20 13:05:38 MDT 2004> last_time <Mon Sep 20 13:05:33 MDT 2004> jib:~ > cat b.rb require 'bdb' db = BDB::Btree.open "bdb", nil, BDB::CREATE, 0644 this_time = Time::now last_time = nil last_time = db['time'] db['time'] = this_time puts "this_time <#{ this_time }>" puts "last_time <#{ last_time }>" db.close jib:~ > ruby b.rb this_time <Mon Sep 20 13:10:55 MDT 2004> last_time <> jib:~ > ruby b.rb this_time <Mon Sep 20 13:10:56 MDT 2004> last_time <Mon Sep 20 13:10:55 MDT 2004> jib:~ > ruby b.rb this_time <Mon Sep 20 13:11:01 MDT 2004> last_time <Mon Sep 20 13:10:56 MDT 2004> regards. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen =============================================================================== --8323328-832260909-10957075268837-- --8323328-832260909-10957075268837--