Object without Undo?
Hi All, I'm creating an "infinite-set" type product which generates objects on-the-fly based on their URL. In general many more objects are possible than are reasonable to store, yet relatively few would be used at any one time. Hence, a sensible approach is to provide a cache of recently requested objects and serve from the cache whenever feasible. After several design iterations, and one (mostly) working model, which unfortunately didn't scale too well, I've decided on actually inheriting from "ObjectManager" and storing the objects in the main object. As objects expire from the cache, they are deleted. However, with the way Zope's database works, I have to wonder if I'm actually acheiving anything -- the deleted files are still taking up space until the database is packed! So, I'm wondering if (via Zope's API, as this is a Python-based product), there's a way to mark an object as not undoable -- i.e. when it gets deleted, it's really gone. The alternative would seem to be to pack the whole database frequently. Which is what I'll do if there's no other way. It appears that I can get the desired behavior by overloading the _getOb() method of ObjectManager and catching the case of a request for a non-existent object -- if it happens, I just call the code to make the object, add it with _setObject() and then let _getOb() continue with the request, which should now succeed. I presume this would make the cached object visible to Zope calls in all the usual ways (e.g. URL: "parent/cached_obj", Python: "parent.cached_obj", etc). My previous implementation used __getattr__() directly and only worked for the URL approach. Any comments or ideas appreciated, thanks! Terry -- ------------------------------------------------------ Terry Hancock hancock@anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com P.O. Box 60583 Pasadena, CA 91116-6583 ------------------------------------------------------
On Fri, Apr 12, 2002 at 06:47:11AM -0700, Terry Hancock wrote:
Hi All,
I'm creating an "infinite-set" type product which generates objects on-the-fly based on their URL. In general many more objects are possible than are reasonable to store, yet relatively few would be used at any one time. Hence, a sensible approach is to provide a cache of recently requested objects and serve from the cache whenever feasible.
Interesting and weird idea... I'm having a hard time imagining an application. Why do you need so many objects? So, I'm wondering if (via Zope's API, as this is a Python-based
product), there's a way to mark an object as not undoable -- i.e. when it gets deleted, it's really gone.
Well, if your objects don't inherit from something which is persistent, they won't get stored in the ZODB at all, AFAIK. They'll simply exist in memory until deleted or until zope restarts, whichever comes first. But I haven't really looked into it closely. -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
Terry Hancock writes:
I'm creating an "infinite-set" type product which generates objects on-the-fly based on their URL. In general many more objects are possible than are reasonable to store, yet relatively few would be used at any one time. Hence, a sensible approach is to provide a cache of recently requested objects and serve from the cache whenever feasible.
... ZODB based cache ... You can use "temp_folders" that come with Zope 2.5. They provide temporary storage (in RAM).
Alternatively, you can look at "MountableStorage" (or something like that) and a BerkeleyStorage (it is non-undoable, file based). Dieter
On Sun, Apr 14, 2002 at 11:45:17PM +0200, Dieter Maurer wrote: You can use "temp_folders" that come with Zope 2.5.
They provide temporary storage (in RAM).
WOW, that is cool. -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
participants (3)
-
Dieter Maurer -
Paul Winkler -
Terry Hancock