On Wed, 2009-02-25 at 14:04 +0100, Matteo Pelucco wrote:
> Jan Haderka ha scritto:
> >> Next step is to remove that bypasses and try to flush cash every 15
> >> minutes for these pages..
> >
> > For this you need to write your own CachePolicy.
>
> Maybe in next releases new caching mechanisms can be implemented by
> default ;-)
Maybe. If you create an issue and pack related code you will write for
your project as a patch it might be even quite soon :)
>
> > Have a look at info.magnolia.module.cache.cachepolicy.Default for an
> > example. This policy will suggest caching the page only once and then
> > always suggest to use cached copy of the requested page. So in your case
> > what you want to do in shouldCache() method is to have extra condition
> > like:
> >
> > if (request.uri matches listOfPagesToBeFlushedEvery15Min) {
> > caheEntry = getCacheEntry(key)
> > if (cacheEntry.created + 15min < CurrentTime) {
> > return CachePolicyResult.store;
> > }
> > }
>
> Only one question: how can I get this amount: cacheEntry.created ?
I thought we store this ... but actually we don't. OTOH there is
((CachedPage) cacheEntry).getLastModificationDate() which should be
enough, no? If the entry was not modified then there is no need to
refresh it. Unless of course you are pulling some dynamic data from
elsewhere and they are not directly part of the content. In that case
you have few options. You can maintain in-memory list/map of last time
you generated entry directly in cachePolicy. Or you can maintain such
list in special workspace or completely outside of Magnolia (say in
separate datapase). Or you can add such property to the CachedPage and
set it CachedPage constructor. If you decide to extend CachedPage you
would have to also extend Store executor (makeCachedEntry() method) to
use your extended CachedPage instead of the default one (hmm, perhaps
you can create issue to use FactoryUtils or similar to instantiate
CachedPage so it can be interchanged with some other implementation).
... It all sounds way too complicated :( ... if you are using default
cache engine (ehCache) you might try this while executing
CachePolicy.shouldCache():
Ehcache ehcache = ((EhCacheWrapper) cache).getWrappedCache();
ehcache.get(key).getCreationTime();
Cheers,
Jan
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------