| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | 
							- <?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
 
- class Cache {
 
- 	/**
 
- 	 * All of the active cache drivers.
 
- 	 *
 
- 	 * @var array
 
- 	 */
 
- 	public static $drivers = array();
 
- 	/**
 
- 	 * Get a cache driver instance.
 
- 	 *
 
- 	 * If no driver name is specified, the default will be returned.
 
- 	 *
 
- 	 * <code>
 
- 	 *		// Get the default cache driver instance
 
- 	 *		$driver = Cache::driver();
 
- 	 *
 
- 	 *		// Get a specific cache driver instance by name
 
- 	 *		$driver = Cache::driver('memcached');
 
- 	 * </code>
 
- 	 *
 
- 	 * @param  string        $driver
 
- 	 * @return Cache\Driver
 
- 	 */
 
- 	public static function driver($driver = null)
 
- 	{
 
- 		if (is_null($driver)) $driver = Config::get('cache.driver');
 
- 		if ( ! isset(static::$drivers[$driver]))
 
- 		{
 
- 			static::$drivers[$driver] = static::factory($driver);
 
- 		}
 
- 		return static::$drivers[$driver];
 
- 	}
 
- 	/**
 
- 	 * Create a new cache driver instance.
 
- 	 *
 
- 	 * @param  string  $driver
 
- 	 * @return Driver
 
- 	 */
 
- 	protected static function factory($driver)
 
- 	{
 
- 		switch ($driver)
 
- 		{
 
- 			case 'apc':
 
- 				return new Cache\Drivers\APC(Config::get('cache.key'));
 
- 			case 'file':
 
- 				return new Cache\Drivers\File(CACHE_PATH);
 
- 			case 'memcached':
 
- 				return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key'));
 
- 			case 'redis':
 
- 				return new Cache\Drivers\Redis(Redis::db());
 
- 			case 'database':
 
- 				return new Cache\Drivers\Database(Config::get('cache.key'));
 
- 			default:
 
- 				throw new \Exception("Cache driver {$driver} is not supported.");
 
- 		}
 
- 	}
 
- 	/**
 
- 	 * Magic Method for calling the methods on the default cache driver.
 
- 	 *
 
- 	 * <code>
 
- 	 *		// Call the "get" method on the default cache driver
 
- 	 *		$name = Cache::get('name');
 
- 	 *
 
- 	 *		// Call the "put" method on the default cache driver
 
- 	 *		Cache::put('name', 'Taylor', 15);
 
- 	 * </code>
 
- 	 */
 
- 	public static function __callStatic($method, $parameters)
 
- 	{
 
- 		return call_user_func_array(array(static::driver(), $method), $parameters);
 
- 	}
 
- }
 
 
  |