On Wed, 20 Oct 2004 09:59:58 +0100 Dave wrote:
DS> >                                       but the twist is that the value of
DS> > the variables are computed from a common source that is costly to access.
DS> 
DS> OK - so the 'shared_handler' routine caches this value in some way,
DS> and uses that cached value to service incoming requests, only recomputing
DS> it when the cached value gets "too old" (however you want to define this).
DS> 
DS> You should be able to use the 'cache' helper to implement this.

The other option I've used before is to use the data list of the agent request
info pointer. The same agent request pointer is passed to all handlers for teh
varbinds in a given request. In each handler, try to extract the value from the
list. If it isn't there, get the value and put it in the list for any other
instances of the handler. If you have a shared handler for different instances,
you need to make sure you use a unique key for the datalist.

When the request is completed, the data list will be destroyed, and the free
function (if any) will be called. i.e. caching this way only works for the
lifetime of the current request. To cache for longer, the cache helper or any
proprietary caching would be needed.

DS> [The cache helper] was originally designed to slot into the handler chain
DS> and be invoked automatically, but I believe Robert has done some work to
DS> make it useable "standalone".

No, I still use it in the context of an injected handler, though you just made
me realize that in some cases, it shouldn't be (when the cache is refreshed
periodically, instead of only on demand (i.e. incoming request)).

-- 
Robert Story; NET-SNMP Junkie <http://www.net-snmp.org/>
<irc://irc.freenode.net/#net-snmp>
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-coders>

You are lost in a twisty maze of little standards, all different. 


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to