Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bovine/memcached-for-Tcl
Browse files Browse the repository at this point in the history
  • Loading branch information
bovine committed Apr 9, 2017
2 parents eaf06bd + 23fbdf2 commit 34a9483
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@

Support additional optional arguments to the incr/decr, which use memcached_increment_with_initial and memcached_decrement_with_initial internally when necessary. (Note: MEMCACHED_BEHAVIOR_BINARY_PROTOCOL must be enabled first before using the extra arguments.)

2016-11-22 Danilo Chang <[email protected]>

Add prepend and flush command

2016-11-11 Jeff Lawson <[email protected]>

Release of version 1.2.0

Support Unicode strings as values for get/set/add/append/replace operations.

2016-06-03 Jeff Lawson <[email protected]>

Ensure "get" always returns an error code is if memcached_get() returns N…ULL.

2016-06-01 Jeff Lawson <[email protected]>

Release of version 1.1.1
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ Available Commands

memcache append key value ?expires? ?flags?

memcache prepend key value ?expires? ?flags?

memcache set key value ?expires? ?flags?

memcache replace key value ?expires? ?flags?

memcache delete key ?expires?

memcache flush ?expires?

memcache incr key value ?varname?

memcache decr key value ?varname?
Expand Down
31 changes: 27 additions & 4 deletions generic/tclMemcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ static int Memcache_Cmd(ClientData arg, Tcl_Interp * interp, int objc, Tcl_Obj *

// list of supported commands that we expose.
enum {
cmdGet, cmdAdd, cmdAppend, cmdSet, cmdReplace,
cmdDelete, cmdIncr, cmdDecr, cmdVersion, cmdServer, cmdBehavior
cmdGet, cmdAdd, cmdAppend, cmdPrepend, cmdSet, cmdReplace,
cmdDelete, cmdFlush, cmdIncr, cmdDecr, cmdVersion, cmdServer, cmdBehavior
};

static CONST char *sCmd[] = {
"get", "add", "append", "set", "replace",
"delete", "incr", "decr", "version", "server", "behavior",
"get", "add", "append", "prepend", "set", "replace",
"delete", "flush", "incr", "decr", "version", "server", "behavior",
0
};

Expand Down Expand Up @@ -186,12 +186,14 @@ static int Memcache_Cmd(ClientData arg, Tcl_Interp * interp, int objc, Tcl_Obj *
case cmdAdd:
case cmdSet:
case cmdAppend:
case cmdPrepend:
case cmdReplace:
/*
* Store a new value into the cache:
*
* - memcache add key value ?expires? ?flags?
* - memcache append key value ?expires? ?flags?
* - memcache prepend key value ?expires? ?flags?
* - memcache set key value ?expires? ?flags?
* - memcache replace key value ?expires? ?flags?
*/
Expand All @@ -214,6 +216,9 @@ static int Memcache_Cmd(ClientData arg, Tcl_Interp * interp, int objc, Tcl_Obj *
case cmdAppend:
result = memcached_append(get_memc(), key, strlen(key), data, isize, expires, flags);
break;
case cmdPrepend:
result = memcached_prepend(get_memc(), key, strlen(key), data, isize, expires, flags);
break;
case cmdSet:
result = memcached_set(get_memc(), key, strlen(key), data, isize, expires, flags);
break;
Expand Down Expand Up @@ -244,6 +249,24 @@ static int Memcache_Cmd(ClientData arg, Tcl_Interp * interp, int objc, Tcl_Obj *
break;


case cmdFlush:
/*
* Wipe clean the contents of memcached servers:
*
* - memcache flush ?expires?
*/
if (objc != 2 && objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "?expires?");
return TCL_ERROR;
}
if (objc == 3) {
expires = atoi(Tcl_GetString(objv[2]));
}
result = memcached_flush(get_memc(), expires);
Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
break;


case cmdIncr:
case cmdDecr:
/*
Expand Down

0 comments on commit 34a9483

Please sign in to comment.