-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1044255
Showing
5 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2017 Will Mather | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#Laravel Wincache Driver | ||
|
||
## Installation | ||
|
||
This repository is to replace the Wincache Cache Driver removed from Laravel 5.2. As such it only works in 5.2 and higher. | ||
|
||
```bash | ||
$ composer require wmather/wincache | ||
``` | ||
|
||
Or a manual update of your composer.json | ||
|
||
```json | ||
{ | ||
"require": { | ||
"wmather/wincache": "^1.0" | ||
} | ||
} | ||
``` | ||
|
||
After installing, register the service provider by adding this line to the `providers` array in `config/app.php`. | ||
|
||
* `Wmather\WinCache\WinCacheStoreServiceProvider::class` | ||
|
||
In your config/cache.php, add a new entry to the `stores` array | ||
|
||
``` | ||
'wincache' => [ | ||
'driver' => 'wincache', | ||
], | ||
``` | ||
|
||
And then in your `.env` file, set the CACHE_DRIVER to that alias | ||
|
||
``` | ||
CACHER_DRIVE=wincache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "wmather/wincache", | ||
"description": "Package to return the Wincache Cache Driver to Laravel 5.2+", | ||
"keywords": ["laravel", "framework", "wincache", "store", "cache", "cache driver", "cache store"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Will Mather" | ||
} | ||
], | ||
|
||
"require": { | ||
"php": ">=5.5.9", | ||
"laravel/framework": "~5.2" | ||
}, | ||
|
||
"autoload": { | ||
"psr-4": { | ||
"Wmather\\WinCache\\": "src/" | ||
} | ||
}, | ||
|
||
"config": { | ||
"preferred-install": "dist" | ||
}, | ||
|
||
"minimum-stability": "stable", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
|
||
namespace Wmather\WinCache; | ||
|
||
use Illuminate\Contracts\Cache\Store; | ||
use Illuminate\Cache\TaggableStore; | ||
use Illuminate\Cache\RetrievesMultipleKeys; | ||
|
||
class WinCacheStore extends TaggableStore implements Store | ||
{ | ||
|
||
use RetrievesMultipleKeys; | ||
|
||
/** | ||
* A string that should be prepended to keys. | ||
* | ||
* @var string | ||
*/ | ||
protected $prefix; | ||
|
||
/** | ||
* Create a new WinCache store. | ||
* | ||
* @param string $prefix | ||
* @return void | ||
*/ | ||
public function __construct($prefix = '') | ||
{ | ||
$this->prefix = $prefix; | ||
} | ||
|
||
/** | ||
* Retrieve an item from the cache by key. | ||
* | ||
* @param string $key | ||
* @return mixed | ||
*/ | ||
public function get($key) | ||
{ | ||
$value = wincache_ucache_get($this->prefix.$key); | ||
|
||
if ($value !== false) { | ||
return $value; | ||
} | ||
} | ||
|
||
/** | ||
* Store an item in the cache for a given number of minutes. | ||
* | ||
* @param string $key | ||
* @param mixed $value | ||
* @param int $minutes | ||
* @return void | ||
*/ | ||
public function put($key, $value, $minutes) | ||
{ | ||
wincache_ucache_set($this->prefix.$key, $value, $minutes * 60); | ||
} | ||
|
||
/** | ||
* Increment the value of an item in the cache. | ||
* | ||
* @param string $key | ||
* @param mixed $value | ||
* @return int|bool | ||
*/ | ||
public function increment($key, $value = 1) | ||
{ | ||
return wincache_ucache_inc($this->prefix.$key, $value); | ||
} | ||
|
||
/** | ||
* Increment the value of an item in the cache. | ||
* | ||
* @param string $key | ||
* @param mixed $value | ||
* @return int|bool | ||
*/ | ||
public function decrement($key, $value = 1) | ||
{ | ||
return wincache_ucache_dec($this->prefix.$key, $value); | ||
} | ||
|
||
/** | ||
* Store an item in the cache indefinitely. | ||
* | ||
* @param string $key | ||
* @param mixed $value | ||
* @return void | ||
*/ | ||
public function forever($key, $value) | ||
{ | ||
$this->put($key, $value, 0); | ||
} | ||
|
||
/** | ||
* Remove an item from the cache. | ||
* | ||
* @param string $key | ||
* @return bool | ||
*/ | ||
public function forget($key) | ||
{ | ||
return wincache_ucache_delete($this->prefix.$key); | ||
} | ||
|
||
/** | ||
* Remove all items from the cache. | ||
* | ||
* @return void | ||
*/ | ||
public function flush() | ||
{ | ||
wincache_ucache_clear(); | ||
} | ||
|
||
/** | ||
* Get the cache key prefix. | ||
* | ||
* @return string | ||
*/ | ||
public function getPrefix() | ||
{ | ||
return $this->prefix; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Wmather\WinCache; | ||
|
||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class WinCacheStoreServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Perform post-registration booting of services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
Cache::extend('wincache', function ($app) { | ||
return Cache::repository(new WinCacheStore); | ||
}); | ||
} | ||
|
||
/** | ||
* Register bindings in the container. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |