diff --git a/doc/ns_cache.n b/doc/ns_cache.n index 6c35cf9..5fd3f04 100644 --- a/doc/ns_cache.n +++ b/doc/ns_cache.n @@ -27,7 +27,7 @@ '\" version of this file under either the License or the GPL. '\" '\" -'\" $Header: /Users/dossy/Desktop/cvs/aolserver/doc/ns_cache.n,v 1.5 2006/04/13 19:05:43 jgdavidson Exp $ +'\" $Header: /Users/dossy/Desktop/cvs/aolserver/doc/ns_cache.n,v 1.6 2009/01/31 21:35:08 gneumann Exp $ '\" '\" '\" transliterated from index.html by davis@xarg.net 2002-11-10 @@ -49,7 +49,7 @@ ns_cache \- Cache arbitrary data \fBns_cache get \fIcachename key \fR?\fIvarname\fR? \fBns_cache incr \fIcachename key ?value?\fR \fBns_cache lappend \fIcachename key string ?string ...?\fR -\fBns_cache names \fIcachename\fR +\fBns_cache names \fIcachename ?pattern?\fR \fBns_cache set \fIcachename key string\fR .fi .BE @@ -118,8 +118,10 @@ if the key is missing an error is raised. If \fIvarname\fR is provided and the key exists the command sets \fIvarname\fR to the value and returns 1, otherwise it returns 0. .TP -\fBns_cache names \fIcachename\fR +\fBns_cache names \fIcachename ?pattern?\fR This command returns a list of all keys currently in the specified cache. +If \fIpattern\fR is specified, only matching entries are returned +(match pattern syntax like in \fBstring match\fR). If the cache is thread-private, then the list only includes keys that are in the thread's private cache. diff --git a/nsd/tclcache.c b/nsd/tclcache.c index 545e98e..805dd8b 100644 --- a/nsd/tclcache.c +++ b/nsd/tclcache.c @@ -33,7 +33,7 @@ * Tcl API for cache.c. Based on work from the nscache module. */ -static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/tclcache.c,v 1.2 2005/08/01 20:29:24 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__; +static const char *RCSID = "@(#) $Header: /Users/dossy/Desktop/cvs/aolserver/nsd/tclcache.c,v 1.3 2009/01/31 21:35:08 gneumann Exp $, compiled: " __DATE__ " " __TIME__; #include "nsd.h" @@ -391,6 +391,7 @@ NsTclCacheObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) Tcl_WrongNumArgs(interp, 3, objv, "key script"); return TCL_ERROR; } + status = TCL_OK; key = Tcl_GetString(objv[3]); Ns_CacheLock(cachePtr->cache); entry = Ns_CacheCreateEntry(cachePtr->cache, key, &new); @@ -438,13 +439,17 @@ NsTclCacheObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) status = Tcl_EvalObjEx(interp, objv[4], 0); Ns_CacheLock(cachePtr->cache); entry = Ns_CacheCreateEntry(cachePtr->cache, key, &new); - if (status != TCL_OK) { - Ns_CacheFlushEntry(entry); - err = 1; - } else { + + if (status == TCL_OK || status == TCL_RETURN) { objPtr = Tcl_GetObjResult(interp); valPtr = NewVal(cachePtr, objPtr, &now); Ns_CacheSetValueSz(entry, valPtr, valPtr->length); + + if (status == TCL_RETURN) { + status = TCL_OK; + } + } else { + Ns_CacheFlushEntry(entry); } Ns_CacheBroadcast(cachePtr->cache); } @@ -453,6 +458,8 @@ NsTclCacheObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) if (err) { return TCL_ERROR; } + + return status; break; } return TCL_OK;