# If you want different things cached for authorize and post-auth,
# you will need to define two instances of the "cache" module.
#
-# The module returns "updated" if it found a cache entry.
-# The module returns "ok" if it added a new cache entry.
+# The module returns "ok" if it found a cache entry.
+# The module returns "updated" if it added a new cache entry.
# The module returns "noop" if it did nothing.
#
cache {
#
# You should ALWAYS leave it as "epoch = 0" here.
epoch = 0
+
+ # The module can also operate in status-only mode where it will
+ # not add new cache entries, or merge existing ones.
+ #
+ # To enable set the control variable "Cache-Status-Only" to "yes"
+ # The module will return "ok" if it found a cache entry.
+ # The module will return "notfound" if it failed to find a cache entry,
+ # or the entry had expired.
+ #
+ # Note: expired entries will still be removed.
# The list of attributes to cache for a particular key.
# Each key gets the same set of cached attributes.
# You can specify which list the attribute goes into by
# prefixing the attribute name with the list. This allows
# you to update multiple lists with one configuration.
- update cache {
+ #
+ # If no list is specified the request list will be updated.
+ attributes {
# list:Attr-Name
- reply:Filter-Id += "%l"
+ reply:Reply-Message += "I'm the cached reply from %t"
control:Class := 0x010203
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
- * Copyright 2000,2006 The FreeRADIUS server project
- * Copyright 2000 your name <your address>
+ * Copyright 2012 The FreeRADIUS server project
*/
#include <freeradius-devel/ident.h>
if ((c->expires < request->timestamp) ||
(c->created < inst->epoch)) {
delete:
+ DEBUG("rlm_cache: Entry has expired, removing");
+
fr_heap_extract(inst->heap, c);
rbtree_deletebydata(inst->cache, c);
+
return NULL;
}
+ DEBUG("rlm_cache: Found entry for \"%s\"", key);
+
/*
* Update the expiry time based on the TTL.
* A TTL of 0 means "delete from the cache".
vp = pairfind(request->config_items, PW_CACHE_TTL);
if (vp) {
if (vp->vp_integer == 0) goto delete;
-
+
ttl = vp->vp_integer;
- } else {
- ttl = inst->ttl;
+ c->expires = request->timestamp + ttl;
+ DEBUG("rlm_cache: Adding %d to the TTL", ttl);
}
- DEBUG("rlm_cache: Found entry for \"%s\". Adding %d to the TTL",
- key, ttl);
- c->expires = request->timestamp + ttl;
-
return c;
}
{ "ttl", PW_TYPE_INTEGER,
offsetof(rlm_cache_t, ttl), NULL, "500" },
{ "epoch", PW_TYPE_INTEGER,
- offsetof(rlm_cache_t, epoch), NULL, NULL },
+ offsetof(rlm_cache_t, epoch), NULL, "0" },
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
cache_detach(inst);
return -1;
}
+
+ if (inst->epoch != 0){
+ radlog(L_ERR, "rlm_cache: Epoch should only be set dynamically");
+ cache_detach(inst);
+ return -1;
+ }
/*
* The cache.
cache_detach(inst);
return -1;
}
+
inst->cs = cf_section_sub_find(conf, "update");
if (!inst->cs) {
{
rlm_cache_entry_t *c;
rlm_cache_t *inst = instance;
+ VALUE_PAIR *vp;
char buffer[1024];
radius_xlat(buffer, sizeof(buffer), inst->key, request, NULL);
c = cache_find(inst, request, buffer);
+
+ /*
+ * If yes, only return whether we found a valid cache entry
+ */
+ vp = pairfind(request->config_items, PW_CACHE_STATUS_ONLY);
+ if (vp && vp->vp_integer) {
+ return c ?
+ RLM_MODULE_OK:
+ RLM_MODULE_NOTFOUND;
+ }
+
if (c) {
cache_merge(request, c);
- return RLM_MODULE_UPDATED;
+ return RLM_MODULE_OK;
}
c = cache_add(inst, request, buffer);
cache_merge(request, c);
- return RLM_MODULE_OK;
+ return RLM_MODULE_UPDATED;
}