1
0
Fork 0

closes #174: updated api for clear all cache

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@976 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 11 years ago
parent 5aa5f6ee66
commit 032a12aeea

@ -1,6 +1,12 @@
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
ChangeLog

@ -238,13 +238,13 @@ function processClear()
$cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0);
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);
}
}
else {
xcache_clear_cache($type, $cacheid);
xcache_clear_cache($type);
}
}
}
@ -271,7 +271,7 @@ for ($i = 0; $i < $pcnt; $i ++) {
if ($pcnt >= 2) {
$total['type'] = XC_TYPE_PHP;
$total['cache_name'] = _T('Total');
$total['cacheid'] = $pcnt;
$total['cacheid'] = -1;
$total['gc'] = null;
$total['istotal'] = true;
$cacheinfos[] = $total;
@ -295,7 +295,7 @@ for ($i = 0; $i < $vcnt; $i ++) {
if ($vcnt >= 2) {
$total['type'] = XC_TYPE_VAR;
$total['cache_name'] = _T('Total');
$total['cacheid'] = $vcnt;
$total['cacheid'] = -1;
$total['gc'] = null;
$total['istotal'] = true;
$cacheinfos[] = $total;

@ -2682,6 +2682,21 @@ static int xcache_admin_auth_check(TSRMLS_D) /* {{{ */
return 0;
}
/* }}} */
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;
static void xcache_admin_operate(xcache_op_type optype, INTERNAL_FUNCTION_PARAMETERS)
@ -2697,13 +2712,22 @@ static void xcache_admin_operate(xcache_op_type optype, INTERNAL_FUNCTION_PARAME
RETURN_NULL();
}
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;
}
}
switch (type) {
@ -2746,28 +2770,23 @@ static void xcache_admin_operate(xcache_op_type optype, INTERNAL_FUNCTION_PARAME
}
} LEAVE_LOCK(cache);
break;
case XC_OP_CLEAR:
{
xc_entry_t *e, *next;
int entryslotid, c;
if (!caches || id < -1 || id >= size) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists");
RETURN_FALSE;
}
if (!caches || id < 0 || 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;
default:
@ -2796,7 +2815,7 @@ PHP_FUNCTION(xcache_list)
xcache_admin_operate(XC_OP_LIST, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ 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)
{

Loading…
Cancel
Save