On Tue, 21 Jan 2003 12:23 pm, Tom Sawyer wrote:
> but it did get me thinking that it would be neat is Ruby could cache its
> ObjectSpace to disk, or more exactly, if it could track object usage and
> cache the objects with oldest/least use. then Ruby in and of itself could
> be persistent, and work as a general purpose soultion.

This idea intrigues me, but I'm grappling with what implementation would be 
most useful, and whether it could be written as a library or would need to be 
more built in to Ruby itself. That would depend on how it was done. Of course 
the purpose is not simply to cache the objects to disk, but to do it in some 
way that allows another Ruby process that could be runnning an arbitrary 
amount of time later to reconstitute those objects in a useful manner. It 
would also need to have flexible hooks that allow custom objects to cache 
themselves as they see fit.

Hmm, so far this sounds alot like module Marshal, but with a few extra 
features. What it would need that Marshal doesn't have is the consistency 
checking that Prevayler has ('snapshots' and transaction lists) and a fair 
bit more transparency (no need to call Marshal.dump/Marshal.restore 
manually). Perhaps it could be written as a wrapper around Marshal. Each 
object or class that needs to be cached can 'extend' (to cache individual 
objects) or 'include' (to cache every object of a particular class) a module 
that flags this object as needing caching, and watches for changes in the 
object's state (somehow...) to mark as transactions. Then, on exit or 
whenever else appropriate, it dumps all its info to disk to be called up 
again next time around.

No implementation details yet, but does this sound useful?

Tim Bates
-- 
tim / bates.id.au