1: <?php
2:
3:
4: 5: 6:
7: class QCacheProviderMemcache extends QAbstractCacheProvider {
8:
9: protected $objMemcache;
10:
11: 12: 13: 14: 15:
16: public function __construct($objOptionsArray) {
17: $this->objMemcache = new Memcache();
18: foreach ($objOptionsArray as $objServerOptions) {
19: $host = $objServerOptions["host"];
20: $port = array_key_exists("port", $objServerOptions) ? $objServerOptions["port"] : 11211;
21: $persistent = array_key_exists("persistent", $objServerOptions) ? $objServerOptions["persistent"] : true;
22: $weight = array_key_exists("weight", $objServerOptions) ? $objServerOptions["weight"] : 10;
23: $timeout = array_key_exists("timeout", $objServerOptions) ? $objServerOptions["timeout"] : 1;
24: $retry_interval = array_key_exists("retry_interval", $objServerOptions) ? $objServerOptions["retry_interval"] : 15;
25: $status = array_key_exists("status", $objServerOptions) ? $objServerOptions["status"] : true;
26: $failure_callback = array_key_exists("failure_callback", $objServerOptions) ? $objServerOptions["failure_callback"] : null;
27: $this->objMemcache->addserver($host, $port, $persistent, $weight, $timeout, $retry_interval, $status, $failure_callback);
28: }
29: }
30:
31: 32: 33: 34: 35:
36: public function Get($strKey) {
37: return $this->objMemcache->get($strKey);
38: }
39:
40: 41: 42: 43: 44: 45:
46: public function Set($strKey, $objValue) {
47: $this->objMemcache->set($strKey, $objValue);
48: }
49:
50: 51: 52: 53: 54:
55: public function Delete($strKey) {
56: $this->objMemcache->delete($strKey);
57: }
58:
59: 60: 61: 62:
63: public function DeleteAll() {
64: $this->objMemcache->flush();
65:
66:
67: sleep(1);
68: }
69: }