Commit 15887af9 authored by Taylor Otwell's avatar Taylor Otwell

Merge branch 'master' into develop

parents 6ba37d42 ab152200
...@@ -79,6 +79,9 @@ class Cache { ...@@ -79,6 +79,9 @@ class Cache {
case 'database': case 'database':
return new Cache\Drivers\Database(Config::get('cache.key')); return new Cache\Drivers\Database(Config::get('cache.key'));
case 'wincache':
return new Cache\Drivers\WinCache(Config::get('cache.key'));
default: default:
throw new \Exception("Cache driver {$driver} is not supported."); throw new \Exception("Cache driver {$driver} is not supported.");
} }
......
<?php namespace Laravel\Cache\Drivers;
class WinCache extends Driver {
/**
* The cache key from the cache configuration file.
*
* @var string
*/
protected $key;
/**
* Create a new WinCache cache driver instance.
*
* @param string $key
* @return void
*/
public function __construct($key)
{
$this->key = $key;
}
/**
* Determine if an item exists in the cache.
*
* @param string $key
* @return bool
*/
public function has($key)
{
return ( ! is_null($this->get($key)));
}
/**
* Retrieve an item from the cache driver.
*
* @param string $key
* @return mixed
*/
protected function retrieve($key)
{
if (($cache = wincache_ucache_get($this->key.$key)) !== false)
{
return $cache;
}
}
/**
* Write an item to the cache for a given number of minutes.
*
* <code>
* // Put an item in the cache for 15 minutes
* Cache::put('name', 'Taylor', 15);
* </code>
*
* @param string $key
* @param mixed $value
* @param int $minutes
* @return void
*/
public function put($key, $value, $minutes)
{
wincache_ucache_add($this->key.$key, $value, $minutes * 60);
}
/**
* Write an item to the cache that lasts forever.
*
* @param string $key
* @param mixed $value
* @return void
*/
public function forever($key, $value)
{
return $this->put($key, $value, 0);
}
/**
* Delete an item from the cache.
*
* @param string $key
* @return void
*/
public function forget($key)
{
wincache_ucache_delete($this->key.$key);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment