Re: Get by group?
Chris Miller <[email protected]>
| Newsgroups | gmane.comp.java.open-symphony.os-cache |
|---|---|
| Message-ID | <[email protected]> |
I'm not sure about how your first request (retrieving all objects in a group) would be implemented... In particular, how would you suggest this work wrt specifying a refresh period or cron expiry when retrieving the group? If ANY content in the group was deemed to be expired (determined by iterating the entire group), I guess the 'sensible' thing to do is to flush the group. Which would mean what, throwing a NeedsRefreshException and bundling the whole group with it? What then happens with content that is in multiple groups - cascading the group flushing sounds potentially very messy. To tackle your second problem I think you'd be better off storing the group names with your cached objects. That way you can flush the desired group(s) manually yourself as you handle the NeedsRefreshException when retrieving a stale object. Taking a step back however, I get the feeling you're trying to achieve something far beyond what OSCache is trying to provide you. It sounds like you're trying to use OSCache as an in-memory database rather than a caching layer. Even if group retrieval and automated group flushing was added, what would happen when an object was pushed out of the cache not because it expired but because it dropped off the end of the LRUCache? Events would need to be added to catch and handle that too. If additional events were added that were fired by the caching algorithms upon object removal, and a method to retrieve entire groups was added, you could probably build the rest of the plumbing yourself. However I'm not sure this is a good approach. Have you considered caching not individual objects but an entire group's worth as a single cache entry? Thoughts? Chris [email protected] wrote: > All, > > I am using OSCache as a caching API in a servlet based application. The > groups functionality holds great promise for what I need, but isn't quite > there. Why does OSCache not support retrieving a List of objects from the > cache by group name? I can group things in cache, which is great for > expiring a number of related objects at a time, but I can't retrieve those > related objects by the group name. This capability is absolutely imperative > for me. Is anyone else doing something similar? > > The other thing I would like is for the entire group to be expired together > if any member of the group is expired. When an object is expired, the cache > would have to iterate over the groups that that object is a part of and > expire all of the other objects in the cache (expire by group name). The > reason that this part is important is because I would like to provide > methods that return lists of objects in the cache (based on group name), and > I need to be sure the list is complete. If I put the complete list into the > cache, but later on, one or more objects in a group are expired (perhaps > because the size limit has been reached), this list is no longer complete > and I need to go to the database again and retrieve the complete list. > > I would love to hear if someone else is doing something similar and has > figured out a different way of doing it. > > Thanks, > > Chris Black > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/