From: Ara.T.Howard@... Date: 2004-09-21T06:24:39+09:00 Subject: Re: Store object in on disk / mini database --8323328-1407291743-1095714627=:18837 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1407291743-1095714627=: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-1407291743-1095714627=:18837 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 21 Sep 2004, Bill Kelly wrote: > From: "trans. (T. Onoma)" >> On Monday 20 September 2004 04:14 pm, Kristian S=C3=B8rensen wrote: >>> Thanks for both your suggestions! That was just what I needed! :-) >> >> There's also YAML. > [...] >> Nice thing about YAML is that the file it creates is human readable and >> editable! > > Additionally YAML supports a drop-in PStore equivalent, so if your code > is already structured to use PStore, you can a YAML::Store the same way. > > require 'yaml/store' > > ystore =3D YAML::Store.new("my_datafile.ystore") > > # use ystore just as you would a pstore: > > my_hash =3D {"a"=3D>1, "b"=3D>2} > my_array =3D %w(dog cat elephant) > > # store stuff in the database > > ystore.transaction do > ystore["my_hash"] =3D my_hash > ystore["my_array"] =3D my_array > end > > # print out all keys/values in database > > ystore.transaction do > ystore.roots.each do |key| > puts ystore[key].inspect > end > end > > > # note the above code is untested yes - yaml is very, very cool - i use it alot for my own code. a couple of things to be aware of - yaml is alot slower than marshal. if your db has only 10,000 entries = or so this no problem - flock does not work on nfs filesystems (used by pstore an yaml::store) -a -- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D | 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.=20 | --Dogen =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D --8323328-1407291743-1095714627=:18837-- --8323328-1407291743-1095714627=:18837--