Created
April 23, 2014 10:04
-
-
Save vanchelo/11209448 to your computer and use it in GitHub Desktop.
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
<?php | |
use Illuminate\Cache\FileStore; | |
class ExtendedFileStore extends FileStore { | |
/** | |
* Get the expiration time based on the given minutes. | |
* | |
* @param int $seconds | |
* @return int | |
*/ | |
protected function expiration($seconds) // Либо вот этот метод переписать, но только в FileStore | |
{ | |
if ($seconds === 0) return 9999999999; | |
return time() + $seconds; | |
} | |
/** | |
* 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) // Либо вот так сделать, будет работать во всех xxxStore ) | |
{ | |
$minutes = $minutes / 60; | |
return parent::put($key, $value, $minutes); | |
} | |
} |
Если не хочется заморачиваться с сервис провайдером, то в app/start/global.php
use Illuminate\Cache\Repository;
Cache::extend('extendedfile', function ($app) {
$path = $app['config']['cache.path'];
return new Repository(new ExtendedFileStore($app['files'], $path));
});
И соответственно создать файл ExtendedFileStore.php, положить в удобное место и прописать его в composer.json в секцию autoload -> classmap, примерно так (файл лежит в папке app/extenders):
"app/extenders/ExtendedFileStore.php"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Если в своем сервис провайдере то вот так