Index: /trunk/admin/xcache.php
===================================================================
--- /trunk/admin/xcache.php	(revision 934)
+++ /trunk/admin/xcache.php	(revision 976)
@@ -239,5 +239,5 @@
 		if (isset($_POST['clearcache'])) {
 			$count = xcache_count($type);
-			if ($cacheid == $count) {
+			if ($cacheid >= 0) {
 				for ($cacheid = 0; $cacheid < $count; $cacheid ++) {
 					xcache_clear_cache($type, $cacheid);
@@ -245,5 +245,5 @@
 			}
 			else {
-				xcache_clear_cache($type, $cacheid);
+				xcache_clear_cache($type);
 			}
 		}
@@ -272,5 +272,5 @@
 	$total['type'] = XC_TYPE_PHP;
 	$total['cache_name'] = _T('Total');
-	$total['cacheid'] = $pcnt;
+	$total['cacheid'] = -1;
 	$total['gc'] = null;
 	$total['istotal'] = true;
@@ -296,5 +296,5 @@
 	$total['type'] = XC_TYPE_VAR;
 	$total['cache_name'] = _T('Total');
-	$total['cacheid'] = $vcnt;
+	$total['cacheid'] = -1;
 	$total['gc'] = null;
 	$total['istotal'] = true;
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 975)
+++ /trunk/xcache.c	(revision 976)
@@ -2683,4 +2683,19 @@
 }
 /* }}} */
+static void xc_clear(long type, xc_cache_t *cache TSRMLS_DC) /* {{{ */
+{
+	xc_entry_t *e, *next;
+	int entryslotid, c;
+
+	ENTER_LOCK(cache) {
+		for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) {
+			for (e = cache->entries[entryslotid]; e; e = next) {
+				next = e->next;
+				xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC);
+			}
+			cache->entries[entryslotid] = NULL;
+		}
+	} LEAVE_LOCK(cache);
+} /* }}} */
 /* {{{ xcache_admin_operate */
 typedef enum { XC_OP_COUNT, XC_OP_INFO, XC_OP_LIST, XC_OP_CLEAR } xcache_op_type;
@@ -2698,11 +2713,20 @@
 	}
 
-	if (optype == XC_OP_COUNT) {
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
-			return;
-		}
-	}
-	else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &type, &id) == FAILURE) {
-		return;
+	switch (optype) {
+		case XC_OP_COUNT:
+			if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
+				return;
+			}
+			break;
+		case XC_OP_CLEAR:
+			id = -1;
+			if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &type, &id) == FAILURE) {
+				return;
+			}
+			break;
+		default:
+			if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &type, &id) == FAILURE) {
+				return;
+			}
 	}
 
@@ -2747,26 +2771,21 @@
 			} LEAVE_LOCK(cache);
 			break;
+
 		case XC_OP_CLEAR:
-			{
-				xc_entry_t *e, *next;
-				int entryslotid, c;
-
-				if (!caches || id < 0 || id >= size) {
-					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists");
-					RETURN_FALSE;
+			if (!caches || id < -1 || id >= size) {
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists");
+				RETURN_FALSE;
+			}
+
+			if (id == -1) {
+				for (id = 0; id < size; ++id) {
+					xc_clear(type, caches[id] TSRMLS_CC);
 				}
-
-				cache = caches[id];
-				ENTER_LOCK(cache) {
-					for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) {
-						for (e = cache->entries[entryslotid]; e; e = next) {
-							next = e->next;
-							xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC);
-						}
-						cache->entries[entryslotid] = NULL;
-					}
-				} LEAVE_LOCK(cache);
-				xc_gc_deletes(TSRMLS_C);
-			}
+			}
+			else {
+				xc_clear(type, caches[id] TSRMLS_CC);
+			}
+
+			xc_gc_deletes(TSRMLS_C);
 			break;
 
@@ -2797,5 +2816,5 @@
 }
 /* }}} */
-/* {{{ proto array xcache_clear_cache(int type, int id)
+/* {{{ proto array xcache_clear_cache(int type, [ int id = -1 ])
    Clear cache by id on specified cache type */
 PHP_FUNCTION(xcache_clear_cache)
Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 974)
+++ /trunk/ChangeLog	(revision 976)
@@ -1,5 +1,11 @@
 2.1.0 2012-??-??
- * fixes #972: warning/error when XCache is loaded incorrectly
- * fixes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode
+API Changes
+========
+ * chg: proto array xcache_clear_cache(int type, [ int id = -1 ]). -1 means all cache splits
+ChangeLog
+========
+ * closes #972: warning/error when XCache is loaded incorrectly
+ * closes #73: warn for improper PHP_FCGI_CHILDREN setting fcgi mode
+ * closes #174: updated api for clear all cache
 
 2.0.1 2012-07-14
