Index: trunk/extensions/MobileFrontend/library/WURFL/Storage/Mwmemcache.php |
— | — | @@ -0,0 +1,47 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class WURFL_Storage_Mwmemcache extends WURFL_Storage_Base { |
| 5 | + |
| 6 | + private $expiration; |
| 7 | + private $namespace; |
| 8 | + |
| 9 | + private $defaultParams = array( |
| 10 | + "host" => "127.0.0.1", |
| 11 | + "port" => "11211", |
| 12 | + "namespace" => "wurfl", |
| 13 | + "expiration" => 0 |
| 14 | + ); |
| 15 | + |
| 16 | + public function __construct($params=array()) { |
| 17 | + $currentParams = is_array($params) ? array_merge($this->defaultParams, $params) : $this->defaultParams; |
| 18 | + $this->toFields($currentParams); |
| 19 | + } |
| 20 | + |
| 21 | + private function toFields($params) { |
| 22 | + foreach($params as $key => $value) { |
| 23 | + $this->$key = $value; |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Saves the object. |
| 29 | + * |
| 30 | + * @param string $objectId |
| 31 | + * @param mixed $object |
| 32 | + * @return |
| 33 | + */ |
| 34 | + public function save($objectId, $object) { |
| 35 | + global $wgMemc; |
| 36 | + return $wgMemc->set( $this->encode( $this->namespace, $objectId ), $object, $this->expiration ); |
| 37 | + } |
| 38 | + |
| 39 | + public function load($objectId) { |
| 40 | + global $wgMemc; |
| 41 | + $value = $wgMemc->get( $this->encode( $this->namespace, $objectId ) ); |
| 42 | + return $value ? $value : null; |
| 43 | + } |
| 44 | + |
| 45 | + |
| 46 | + public function clear() { |
| 47 | + } |
| 48 | +} |
Property changes on: trunk/extensions/MobileFrontend/library/WURFL/Storage/Mwmemcache.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 49 | + native |