|
@@ -1,4 +1,4 @@
|
|
|
-<?php namespace Laravel; defined('DS') or die('No direct script access.');
|
|
|
+<?php namespace Laravel; use Closure;
|
|
|
|
|
|
class Cache {
|
|
|
|
|
@@ -9,6 +9,13 @@ class Cache {
|
|
|
*/
|
|
|
public static $drivers = array();
|
|
|
|
|
|
+ /**
|
|
|
+ * The third-party driver registrar.
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ public static $registrar = array();
|
|
|
+
|
|
|
/**
|
|
|
* Get a cache driver instance.
|
|
|
*
|
|
@@ -45,6 +52,11 @@ class Cache {
|
|
|
*/
|
|
|
protected static function factory($driver)
|
|
|
{
|
|
|
+ if (isset(static::$registrar[$driver]))
|
|
|
+ {
|
|
|
+ return static::$registrar[$driver]();
|
|
|
+ }
|
|
|
+
|
|
|
switch ($driver)
|
|
|
{
|
|
|
case 'apc':
|
|
@@ -70,6 +82,18 @@ class Cache {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Register a third-party cache driver.
|
|
|
+ *
|
|
|
+ * @param string $driver
|
|
|
+ * @param Closure $resolver
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public static function register($driver, Closure $resolver)
|
|
|
+ {
|
|
|
+ static::$registrar[$driver] = $resolver;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Magic Method for calling the methods on the default cache driver.
|
|
|
*
|