r91768 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91767‎ | r91768 | r91769 >
Date:22:50, 8 July 2011
Author:preilly
Status:ok (Comments)
Tags:
Comment:
WURFL support in MW Memcache interface
Modified paths:
  • /trunk/extensions/MobileFrontend/library/WURFL/Storage/Mwmemcache.php (added) (history)

Diff [purge]

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
149 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r92597fix issues after code reviewpreilly23:09, 19 July 2011

Comments

#Comment by 😂 (talk | contribs)   23:06, 19 July 2011

Could use a little more docs, and some whitespace cleanup. Otherwise ok :)

Status & tagging log