PingAccess Agent SDK for C
Functions
paa-cache-standalone.h File Reference
#include "apr.h"
#include "apr_pools.h"
#include "paa-config.h"
#include "paa-cache.h"

Go to the source code of this file.

Functions

apr_status_t paa_cache_standalone_create (apr_pool_t *pool, const paa_config *config, const paa_cache **impl)
 

Detailed Description

Header for the paa_cache standalone implementation.

Function Documentation

apr_status_t paa_cache_standalone_create ( apr_pool_t *  pool,
const paa_config config,
const paa_cache **  impl 
)

Creates an instance of a standalone cache.

This cache implementation does not perform any IPC to PingAccess agents in other processes (local or remote). It is multithread-safe and uses a configurable number of background threads to manage the cache.

The cache partitions management of entries across the background threads so each background thread has exclusive access to the data it manages in the cache. Using this approach, each background thread effectively manages its own cache.

When bounded, the cache evicts entries in LRU order once the configured maximum number of entries is reached. Eviction will bring the total number of entries below a configured high watermark.

Regardless of bound, the cache will also periodically sweep for stale entries, governed by a configurable search interval and a token search limit.

This implementation expects the following keys from the configuration:

  • agent.cache.maxTokens (required)
    • The maximum number of sessions and associated agent responses that can be cached.
  • agent.cache.disabled (optional)
    • Disables the cache when set to a non-zero value. All get requests will result in misses.
    • Default value is 0 meaning the cache is enabled
  • agent.cache.standalone.numBgThreads (optional)
    • The number of background threads to use to manage the cache
    • The value must be greater than 0
    • Default value is is 1
  • agent.cache.standalone.msgQueueSize (optional)
    • The size of the queues used to communicate with background threads. This should be a relatively small number (< 64) to avoid situations where contention for the background thread would be more expensive than contacting PingAccess for a policy decision.
    • The value must be greater than 0
    • Default value is 32
  • agent.cache.tokenHighWatermark (optional)
    • An integer percentage of the maxTokens that will be used as the high watermark in the eviction algorithm.
    • The value must be greater than or equal to 0 and less than 100.
    • Default value is 90
  • agent.cache.eviction.interval (optional)
    • The interval in seconds at which the background threads will scan their caches for expired entries
    • The value must be greater than 0
    • Default value is 300
  • agent.cache.eviction.tokenSearchLimit (optional)
    • The number of entries to search, in LRU order, when periodically evicting expired cache entries
    • The value must be greater than 0
    • Default value is 100
Parameters
poolthe pool in which to allocate the structure
configthe configuration used to configure the implementation
implthe output, populated on success
Returns
APR_SUCCESS on success