source: spip-zone/_plugins_/memoization/memo/xcache.inc @ 32480

Last change on this file since 32480 was 32480, checked in by fil@…, 10 years ago

apres quelques tests et debug, retour a l'API complete de cache_inc(key, VALUE, TTL)

File size: 1.2 KB
Line 
1<?php
2
3/*
4mixed cache_get(string key)
5bool  cache_set(string key, mixed value [, int ttl])
6bool  cache_isset(string key)
7bool  cache_unset(string key)
8int   cache_inc(string key[, int value[, int ttl] ])
9int   cache_dec(string key[, int value[, int ttl] ])
10bool  cache_lock(string key)
11bool  cache_unlock(string key)
12*/
13
14# http://xcache.lighttpd.net/wiki/XcacheApi
15
16@define('_CACHE_NAMESPACE', $_SERVER['HTTP_HOST'].':');
17
18function cache_get($key) {
19        return xcache_get(_CACHE_NAMESPACE.$key);
20}
21
22function cache_set($key, $value, $ttl=null) {
23        return is_null($ttl)
24                ? xcache_set(_CACHE_NAMESPACE.$key, $value)
25                : xcache_set(_CACHE_NAMESPACE.$key, $value, $ttl);
26}
27
28function cache_isset($key) {
29        return xcache_isset(_CACHE_NAMESPACE.$key);
30}
31
32function cache_unset($key) {
33        return xcache_unset(_CACHE_NAMESPACE.$key);
34}
35
36function cache_inc($key, $value=null, $ttl=null) {
37        return xcache_inc(_CACHE_NAMESPACE.$key, $value, $ttl);
38}
39
40function cache_dec($key, $value=null, $ttl=null) {
41        return xcache_dec(_CACHE_NAMESPACE.$key, $value, $ttl);
42}
43
44function cache_lock($key) {
45        return cache_inc('lock::'.$key)===1;
46}
47
48function cache_unlock($key) {
49        return cache_unset('lock::'.$key);
50}
51
52?>
Note: See TracBrowser for help on using the repository browser.