Skip to content
Browse files

Adding memcache class for IT to utilize.

  • Loading branch information...
1 parent 9f56cca commit d152ee97c7f0a9b3b40abd6e552fdd74f2e76b6e @brandonsavage brandonsavage committed
Showing with 37 additions and 0 deletions.
  1. +2 −0 Bugzilla.php
  2. +35 −0 cache/BugzillaCacheMemcache.class.php
View
2 Bugzilla.php
@@ -38,6 +38,8 @@
$wgAutoloadClasses['BugzillaCacheMysql'] = $cwd . '/cache/BugzillaCacheMysql.class.php';
$wgAutoloadClasses['BugzillaCacheDummy'] = $cwd . '/cache/BugzillaCacheDummy.class.php';
$wgAutoloadClasses['BugzillaCacheApc'] = $cwd . '/cache/BugzillaCacheApc.class.php';
+$wgAutoloadClasses['BugzillaCacheMemcache'] = $cwd . '/cache/BugzillaCacheMemcache.class.php';
+
View
35 cache/BugzillaCacheMemcache.class.php
@@ -0,0 +1,35 @@
+<?php
+
+class BugzillaCacheMemcache implements BugzillaCacheI
+{
+
+ protected $_memcache;
+
+ public function __construct() {
+ // As much as I detest using a global here, it is necessary to avoid
+ // needing to inject the $wgMemc object, thus breaking the usefulness
+ // of the interface. Using the $wgMemc object is important for the
+ // consistency of the code.
+ global $wgMemc;
+ $this->_memcache = $wgMemc;
+ }
+
+ public function set($key, $value, $ttl = 300) {
+ // Get the wikimedia key style expected
+ $key = wfMemcKey($key);
+ return $this->_memcache->set($key, $value, $ttl);
+ }
+
+ public function get($key) {
+ // Get the wikimedia key style expected
+ $key = wfMemcKey($key);
+ return $this->_memcache->get($key);
+ }
+
+ public function expire($key) {
+ // Get the wikimedia key style expected
+ $key = wfMemcKey($key);
+ return $this->_memcache->delete($key);
+ }
+
+}

0 comments on commit d152ee9

Please sign in to comment.
Something went wrong with that request. Please try again.