From: Charles Hixson Date: 2004-09-13T13:48:10+09:00 Subject: Re: Problem with ensuring consistency .. Finalization?? Robert Klemme wrote: > > "Charles Hixson" schrieb im Newsbeitrag > news:4142336A.4040005@earthlink.net... > >> Sort of. The disk storage is permanent, it's the hash that's >> temporary. I certainly wouldn't want to eat up my ram by holding the >> entire database in ram, when at any one time it didn't need most of it. > > > Ah, ok, that sounds as if you needed a cache. An LRU cache is > relatively straightforward. There might be one on RAA. I remember I > did an experimental implementation once, if you're interested I can > check whether I still have it. The cache seems to be working now... my current problem has to do with the db, which appears to be confusing variable name with variable value. I may need to rename my db variables, which seems an altogether silly requirement, but that's what it looks like may be needed. >> at_exit { flush } # this is run after the files are >> opened and the hash is initialized >> end # initializer >> .. >> end # class >> >> will solve the problem. I've read the description of what it does >> three times, and I still can't be *sure* that the file and class >> variables will still be extant when I run it, but it looks like >> that's the intent. > > .. > > The only thing that at_exit can't help you with is a crash. If for > some reason (e.g. buggy extension) Ruby crashes at_exit won't help you > here. The best (i.e safest) is probably to directly store new data in > the DB and keep a cache of recent used data in mem. If it's that corrupt, perhaps I'm better off not saving the cache. (It should only cost me a few minutes work, and better stale data than corrupt.) > Thanks for your assistance. > > You're welcome! > > Kind regards > > robert Thanks again, Charles