Steve Piercy - Web Site Builder Re: Object caching to reduce overheads
Dec 11, 2007; 10:45
Steve Piercy - Web Site Builder
Re: Object caching to reduce overheads
I have very little experience with caching mechanisms and I'm learning as I go.
How would one clear a cache within a given scope, where the scope is a named cache for a user, for a virtual host, or a server?
I'm curious about what causes Lasso's built in caching mechanism to run slowly. There may be a good reason for their implementation, like it does some things that are considered useful (at the expense of speediness) which could be adopted by Knop. Or it could be sloppiness.
--steve
On Tuesday, December 11, 2007, inbox_js@solve.se (Johan Solve) pronounced:
>To reduce the overheads from configuring navigation, database objects, language >strings etc that's happening over and over again on every page load I'm experimenting >with caching mechanisms. > >My current idea consists of two custom tags and it looks like this when used: > >if: !(knop_cachefetch: -type='lang'); > var: 'lang_nav_key'=(knop_lang: -default='sv'); > $lang_nav_key -> addlanguage(-language='sv', -strings=(map: > 'hem'='hem', > 'loggain'='loggain', > ... > knop_cachestore: -type='lang', -expires=1200; >/if; > > >knop_cachestore stores all page variables of the specified type in a global variable. >It's a rather brutal approach but it gives a very nice automatic and transparent >feeling, almost nothing to configure and it just works. > >knop_cachefetch tries to recreate all those page variables again from the global >variable, if there's a cached version available. It returns true if it was successful >and false if there wasn't a cached copy available. > > >So the idea is to call knop_cachefetch first to try to have all knop object instances >recreated as page vars, and if knop_cachefetch returns false then configure the knop >objects the normal way and call knop_cachestore to cache them for the next page load. > > >Some example timings for a project I'm working on - >Without caching: >Created langauge strings 23 ms >Created database objects 73 ms >Created navigation 142 ms > >With caching: >Created langauge strings 5 ms >Created database objects 8 ms >Created navigation 7 ms > >Really nice... > > >The cache can be forced to refresh simply by adding one more condition to cache_fetch: >if: $cache_refresh || !(knop_cachefetch: -type='database'); >... > > >The caching can also be done per visitor by specifying a session name to use for cache >storage. > >if: !(knop_cachefetch: -type='nav', -session=$session_name); > var: 'nav'=(knop_nav: > -default=($lang_nav_key -> hem), > -root=$siteroot, > -navmethod=$navmethod); > $nav -> insert(-key=($lang_nav_key -> hem), -label=($lang_nav_label -> hem), >-url='/'); > ... > knop_cachestore: -type='nav', -expires=1200, -session=$session_name; >/if; > > >I'm not using Lasso's built in cache tags for this since they seem to have too much >overhead and are way too slow, but I do use thread locking to provide a thread safe >caching mechanism. > >The global variable used for caching is named uniquely for the current site (based on >server_name and response_localpath - response_filepath) and it's also possible to >specify a -name to further isolate the cache storage if needed (for example if >multiple sites are running in the same virtual root and hostname). > > >Comments? Objections? > >
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@StevePiercy.com> <http://www.StevePiercy.com/>
############################################################# This message is sent to you because you are subscribed to the mailing list <knop@lists.montania.se>. To unsubscribe, E-mail to: <knop-off@lists.montania.se> Send administrative queries to <knop-request@lists.montania.se> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/
Dec 11
Johan Solve Object caching to reduce overheads
Dec 11, 2007; 14:14
Johan Solve
Object caching to reduce overheads
Dec 11
Johan Solve Re: Object caching to reduce overheads
Dec 11, 2007; 22:14
Johan Solve
Re: Object caching to reduce overheads
Dec 12
Jolle Carlestam Re: Object caching to reduce overheads
Dec 12, 2007; 06:23
Jolle Carlestam
Re: Object caching to reduce overheads
Dec 12
Johan Solve Re: Object caching to reduce overheads
Dec 12, 2007; 08:39
Johan Solve
Re: Object caching to reduce overheads
Dec 13
Bil Corry Re: Object caching to reduce overheads
Dec 13, 2007; 21:08
Bil Corry
Re: Object caching to reduce overheads
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!