MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
cacachehandl:erM:aaintains aacachefofadataoforsuseybyolowerelevelahandlers.(3)



NAME
       netsnmpcachehandler - Maintains a cache of data for use by lower
       level handlers.



   Functions
       netsnmpcache * netsnmpcachegethead (void)
           get cache head
       netsnmpcache * netsnmpcachefindbyoid (oid *rootoid, int
           rootoidlen)
           find existing cache
       netsnmpcache * netsnmpcachecreate (int timeout, NetsnmpCacheLoad
           *loadhook, NetsnmpCacheFree *freehook, oid *rootoid, int
           rootoidlen)
           returns a cache
       unsigned int netsnmpcachetimerstart (netsnmpcache *cache)
           starts the recurring cacheload callback
       void netsnmpcachetimerstop (netsnmpcache *cache)
           stops the recurring cacheload callback
       netsnmpmibhandler * netsnmpcachehandlerget (netsnmpcache *cache)
           returns a cache handler that can be injected into a given handler
           chain.
       netsnmpmibhandler * netsnmpgetcachehandler (int timeout,
           NetsnmpCacheLoad *loadhook, NetsnmpCacheFree *freehook, oid
           *rootoid, int rootoidlen)
           returns a cache handler that can be injected into a given handler
           chain.
       int netsnmpcachehandlerregister (netsnmphandlerregistration
           *reginfo, netsnmpcache *cache)
           functionally the same as calling netsnmpregisterhandler() but
           also injects a cache handler at the same time for you.
       int netsnmpregistercachehandler (netsnmphandlerregistration
           **reginfo,, int timeout,, NetsnmpCacheLoad **loadhook,,
           NetsnmpCacheFree **freehook)
           functionally the same as calling netsnmpregisterhandler() but
           also injects a cache handler at the same time for you.
       NETSNMPSTATICINLINE char ** buildcachename (const char **name)
       void netsnmpcachereqinfoinsert (netsnmpcache **cache,,
           netsnmpagentrequestinfo **reqinfo,, const char **name)
           Insert the cache information for a given request (PDU).
       netsnmpcache ** netsnmpcachereqinfoextract
           (netsnmpagentrequestinfo **reqinfo,, const char **name)
           Extract the cache information for a given request (PDU).
       netsnmpcache ** netsnmpextractcacheinfo (netsnmpagentrequestinfo
           **reqinfo)
           Extract the cache information for a given request (PDU).
       int netsnmpcachecheckexpired (netsnmpcache **cache)
           Check if the cache timeout has passed.
       int netsnmpcachecheckandreload (netsnmpcache **cache)
           Reload the cache if required.
       int netsnmpcacheisvalid (netsnmpagentrequestinfo **reqinfo,, const
           char **name)
           Is the cache valid for a given request?
       int netsnmpiscachevalid (netsnmpagentrequestinfo **reqinfo)
           for backwards compat
       int netsnmpcachehelperhandler (netsnmpmibhandler **handler,,
           netsnmphandlerregistration **reginfo,, netsnmpagentrequestinfo
           **reqinfo,, netsnmprequestinfo **requests)
           Implements the cache handler.
       void releasecachedresources (unsigned int regNo,, void **clientargs)
           run regularly to automatically release cached resources.

Detailed Description
       This helper checks to see whether the data has been loaded 'recently'
       (according to the timeout for that particular cache) and calls the
       registered 'loadcache' routine if necessary. The lower handlers can
       then work with this local cached data.

       A timeout value of -1 will cause netsnmpcachecheckexpired() to
       always return true, and thus the cache will be reloaded for every
       request.

       To minimze resource use by the agent, a periodic callback checks for
       expired caches, and will call the freecache function for any expired
       cache.

       The loadcache route should return a negative number if the cache was
       not successfully loaded. 0 or any positive number indicates successs.

       Several flags can be set to affect the operations on the cache.

       If NETSNMPCACHEDONTINVALIDATEONSET is set, the freecache method
       will not be called after a set request has processed. It is assumed
       that the lower mib handler using the cache has maintained cache
       consistency.

       If NETSNMPCACHEDONTFREBEFORELOAD is set, the freecache method
       will not be called before the loadcache method is called. It is
       assumed that the loadcache routine will properly deal with being
       called with a valid cache.

       If NETSNMPCACHEDONTFREXPIRED is set, the freecache method will
       not be called with the cache expires. The expired flag will be set, but
       the valid flag will not be cleared. It is assumed that the loadcache
       routine will properly deal with being called with a valid cache.

       If NETSNMPCACHEPRELOAD is set when a the cache handler is created,
       the cache load routine will be called immediately.

       If NETSNMPCACHEDONTAUTORELEASE is set, the periodic callback that
       checks for expired caches will skip the cache. The cache will only be
       checked for expiration when a request triggers the cache handler. This
       is useful if the cache has it's own periodic callback to keep the cache
       fresh.

       If NETSNMPCACHEAUTORELOAD is set, a timer will be set up to reload
       the cache when it expires. This is useful for keeping the cache fresh,
       even in the absence of incoming snmp requests.

       Here are some suggestions for some common situations.

       Cached File: If your table is based on a file that may periodically
       change, you can test the modification date to see if the file has
       changed since the last cache load. To get the cache helper to call the
       load function for every request, set the timeout to -1, which will
       cause the cache to always report that it is expired. This means that
       you will want to prevent the agent from flushing the cache when it has
       expired, and you will have to flush it manually if you detect that the
       file has changed. To accomplish this, set the following flags:

       NETSNMPCACHEDONTFREXPIRED NETSNMPCACHEDONTAUTORELEASE

       Constant (periodic) reload: If you want the cache kept up to date
       regularly, even if no requests for the table are received, you can have
       your cache load routine called periodically. This is very useful if you
       need to monitor the data for changes (eg a LastChanged object). You
       will need to prevent the agent from flushing the cache when it expires.
       Set the cache timeout to the frequency, in seconds, that you wish to
       reload your cache, and set the following flags:

       NETSNMPCACHEDONTFREXPIRED NETSNMPCACHEDONTAUTORELEASE
       NETSNMPCACHEAUTORELOAD

Function Documentation
   int netsnmpcachecheckandreload (netsnmpcache ** cache)
       Reload the cache if required. Definition at line 383 of file
       cachehandler.c.

       References netsnmpcachecheckexpired().

       Referenced by netsnmpcachehelperhandler().

   int netsnmpcachecheckexpired (netsnmpcache ** cache)
       Check if the cache timeout has passed. Sets and return the expired
       flag. Definition at line 368 of file cachehandler.c.

       References atimeready().

       Referenced by netsnmpcachecheckandreload(), and
       releasecachedresources().

   netsnmpcache** netsnmpcachecreate (int timeout,, NetsnmpCacheLoad **
       loadhook,, NetsnmpCacheFree ** freehook,, oid ** rootoid,, int
       rootoidlen)
       returns a cache Definition at line 140 of file cachehandler.c.

       References snmplog(), and SNMPMALOCTYPEDEF.

       Referenced by netsnmpgetcachehandler().

   netsnmpcache** netsnmpcachefindbyoid (oid ** rootoid,, int rootoidlen)
       find existing cache Definition at line 124 of file cachehandler.c.

       References netsnmpoidequals().

   netsnmpcache** netsnmpcachegethead (void)
       get cache head Definition at line 116 of file cachehandler.c.

   netsnmpmibhandler** netsnmpcachehandlerget (netsnmpcache ** cache)
       returns a cache handler that can be injected into a given handler
       chain. Definition at line 245 of file cachehandler.c.

       References netsnmpmibhandlers::flags, netsnmpmibhandlers::myvoid,
       netsnmpcachetimerstart(), netsnmpcreatehandler(), and
       netsnmpmibhandler.

       Referenced by netsnmpcachehandlerregister(), and
       netsnmpgetcachehandler().

   int netsnmpcachehandlerregister (netsnmphandlerregistration ** reginfo,,
       netsnmpcache ** cache)
       functionally the same as calling netsnmpregisterhandler() but also
       injects a cache handler at the same time for you. Definition at line
       293 of file cachehandler.c.

       References netsnmpcachehandlerget(), netsnmpinjecthandler(),
       netsnmpmibhandler, and netsnmpregisterhandler().

   int netsnmpcachehelperhandler (netsnmpmibhandler ** handler,,
       netsnmphandlerregistration ** reginfo,, netsnmpagentrequestinfo **
       reqinfo,, netsnmprequestinfo ** requests)
       Implements the cache handler. next handler called automatically -
       'AUTONEXT'

       next handler called automatically - 'AUTONEXT'

       next handler called automatically - 'AUTONEXT' Definition at line 418
       of file cachehandler.c.

       References netsnmpmibhandlers::flags,
       netsnmphandlerregistrations::handlerName,
       netsnmpagentrequestinfos::mode, netsnmpmibhandlers::myvoid,
       netsnmpcachecheckandreload(), netsnmpcacheisvalid(),
       netsnmpcachereqinfoinsert(), netsnmphandlerregistration,
       netsnmpsetallrequestserror(),
       netsnmphandlerregistrations::rootoid,
       netsnmphandlerregistrations::rootoidlen, and snmplog().

   int netsnmpcacheisvalid (netsnmpagentrequestinfo ** reqinfo,, const
       char ** name)
       Is the cache valid for a given request? Definition at line 400 of file
       cachehandler.c.

       References netsnmpcachereqinfoextract().

       Referenced by netsnmpcachehelperhandler(), and
       netsnmpiscachevalid().

   netsnmpcache** netsnmpcachereqinfoextract (netsnmpagentrequestinfo **
       reqinfo,, const char ** name)
       Extract the cache information for a given request (PDU). Definition at
       line 348 of file cachehandler.c.

       References SNMPFRE.

       Referenced by netsnmpcacheisvalid(), and
       netsnmpextractcacheinfo().

   void netsnmpcachereqinfoinsert (netsnmpcache ** cache,,
       netsnmpagentrequestinfo ** reqinfo,, const char ** name)
       Insert the cache information for a given request (PDU). Definition at
       line 331 of file cachehandler.c.

       References netsnmpcreatedatalist(), and SNMPFRE.

       Referenced by netsnmpcachehelperhandler().

   unsigned int netsnmpcachetimerstart (netsnmpcache ** cache)
       starts the recurring cacheload callback Definition at line 195 of file
       cachehandler.c.

       References snmpalarmregister(), and snmplog().

       Referenced by netsnmpcachehandlerget().

   void netsnmpcachetimerstop (netsnmpcache ** cache)
       stops the recurring cacheload callback Definition at line 225 of file
       cachehandler.c.

       References snmpalarmunregister(), and snmplog().

   netsnmpcache** netsnmpextractcacheinfo (netsnmpagentrequestinfo **
       reqinfo)
       Extract the cache information for a given request (PDU). Definition at
       line 360 of file cachehandler.c.

       References netsnmpcachereqinfoextract().

   netsnmpmibhandler** netsnmpgetcachehandler (int timeout,,
       NetsnmpCacheLoad ** loadhook,, NetsnmpCacheFree ** freehook,, oid **
       rootoid,, int rootoidlen)
       returns a cache handler that can be injected into a given handler
       chain. Definition at line 274 of file cachehandler.c.

       References netsnmpmibhandlers::myvoid, netsnmpcachecreate(),
       netsnmpcachehandlerget(), and netsnmpmibhandler.

       Referenced by netsnmpregistercachehandler().

   int netsnmpiscachevalid (netsnmpagentrequestinfo ** reqinfo)
       for backwards compat netsnmpcacheisvalid() is preferred. Definition
       at line 411 of file cachehandler.c.

       References netsnmpcacheisvalid().

   int netsnmpregistercachehandler (netsnmphandlerregistration ** reginfo,,
       int timeout,, NetsnmpCacheLoad ** loadhook,, NetsnmpCacheFree **
       freehook)
       functionally the same as calling netsnmpregisterhandler() but also
       injects a cache handler at the same time for you. Definition at line
       306 of file cachehandler.c.

       References netsnmpgetcachehandler(), netsnmpinjecthandler(),
       netsnmpmibhandler, netsnmpregisterhandler(),
       netsnmphandlerregistrations::rootoid, and
       netsnmphandlerregistrations::rootoidlen.

   void releasecachedresources (unsigned int regNo,, void ** clientargs)
       run regularly to automatically release cached resources. xxx - method
       to prevent cache from expiring while a request is being processed (e.g.
       delegated request). proposal: set a flag, which would be cleared when
       request finished (which could be acomplished by a dummy data list item
       in agent req info & custom free function). Definition at line 575 of
       file cachehandler.c.

       References netsnmpcachecheckexpired(), releasecachedresources(),
       and snmpalarmregister().

       Referenced by releasecachedresources().



necachehandler: Maintains a cache2ofJdata00for use by lower level handlers.(3)
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™