laravel-6 support

This commit is contained in:
RafficMohammed
2023-01-08 01:17:22 +05:30
parent 1a5c16ae4b
commit 774eed8b0e
4962 changed files with 279380 additions and 297961 deletions

View File

@@ -52,7 +52,7 @@ class ApcStore extends TaggableStore
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -65,7 +65,7 @@ class ApcStore extends TaggableStore
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1)
@@ -77,7 +77,7 @@ class ApcStore extends TaggableStore
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1)
@@ -89,7 +89,7 @@ class ApcStore extends TaggableStore
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)

View File

@@ -36,8 +36,8 @@ class ApcWrapper
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param int $seconds
* @param mixed $value
* @param int $seconds
* @return array|bool
*/
public function put($key, $value, $seconds)
@@ -49,7 +49,7 @@ class ApcWrapper
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value)
@@ -61,7 +61,7 @@ class ApcWrapper
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value)

View File

@@ -0,0 +1,102 @@
<?php
namespace Illuminate\Cache;
use Carbon\Carbon;
class ArrayLock extends Lock
{
/**
* The parent array cache store.
*
* @var \Illuminate\Cache\ArrayStore
*/
protected $store;
/**
* Create a new lock instance.
*
* @param \Illuminate\Cache\ArrayStore $store
* @param string $name
* @param int $seconds
* @param string|null $owner
* @return void
*/
public function __construct($store, $name, $seconds, $owner = null)
{
parent::__construct($name, $seconds, $owner);
$this->store = $store;
}
/**
* Attempt to acquire the lock.
*
* @return bool
*/
public function acquire()
{
$expiration = $this->store->locks[$this->name]['expiresAt'] ?? Carbon::now()->addSecond();
if ($this->exists() && $expiration->isFuture()) {
return false;
}
$this->store->locks[$this->name] = [
'owner' => $this->owner,
'expiresAt' => $this->seconds === 0 ? null : Carbon::now()->addSeconds($this->seconds),
];
return true;
}
/**
* Determine if the current lock exists.
*
* @return bool
*/
protected function exists()
{
return isset($this->store->locks[$this->name]);
}
/**
* Release the lock.
*
* @return bool
*/
public function release()
{
if (! $this->exists()) {
return false;
}
if (! $this->isOwnedByCurrentProcess()) {
return false;
}
$this->forceRelease();
return true;
}
/**
* Returns the owner value written into the driver for this lock.
*
* @return string
*/
protected function getCurrentOwner()
{
return $this->store->locks[$this->name]['owner'];
}
/**
* Releases this lock in disregard of ownership.
*
* @return void
*/
public function forceRelease()
{
unset($this->store->locks[$this->name]);
}
}

View File

@@ -2,9 +2,10 @@
namespace Illuminate\Cache;
use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Support\InteractsWithTime;
class ArrayStore extends TaggableStore
class ArrayStore extends TaggableStore implements LockProvider
{
use InteractsWithTime, RetrievesMultipleKeys;
@@ -15,6 +16,13 @@ class ArrayStore extends TaggableStore
*/
protected $storage = [];
/**
* The array of locks.
*
* @var array
*/
public $locks = [];
/**
* Retrieve an item from the cache by key.
*
@@ -44,7 +52,7 @@ class ArrayStore extends TaggableStore
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -62,7 +70,7 @@ class ArrayStore extends TaggableStore
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function increment($key, $value = 1)
@@ -82,7 +90,7 @@ class ArrayStore extends TaggableStore
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function decrement($key, $value = 1)
@@ -94,7 +102,7 @@ class ArrayStore extends TaggableStore
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)
@@ -162,4 +170,29 @@ class ArrayStore extends TaggableStore
{
return $seconds > 0 ? $this->availableAt($seconds) : 0;
}
/**
* Get a lock instance.
*
* @param string $name
* @param int $seconds
* @param string|null $owner
* @return \Illuminate\Contracts\Cache\Lock
*/
public function lock($name, $seconds = 0, $owner = null)
{
return new ArrayLock($this, $name, $seconds, $owner);
}
/**
* Restore a lock instance using the owner identifier.
*
* @param string $name
* @param string $owner
* @return \Illuminate\Contracts\Cache\Lock
*/
public function restoreLock($name, $owner)
{
return $this->lock($name, 0, $owner);
}
}

View File

@@ -2,13 +2,13 @@
namespace Illuminate\Cache;
use Aws\DynamoDb\DynamoDbClient;
use Closure;
use Illuminate\Contracts\Cache\Factory as FactoryContract;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Support\Arr;
use InvalidArgumentException;
use Aws\DynamoDb\DynamoDbClient;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Contracts\Cache\Factory as FactoryContract;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
/**
* @mixin \Illuminate\Contracts\Cache\Repository
@@ -153,7 +153,7 @@ class CacheManager implements FactoryContract
*/
protected function createFileDriver(array $config)
{
return $this->repository(new FileStore($this->app['files'], $config['path']));
return $this->repository(new FileStore($this->app['files'], $config['path'], $config['permission'] ?? null));
}
/**
@@ -226,21 +226,11 @@ class CacheManager implements FactoryContract
*/
protected function createDynamodbDriver(array $config)
{
$dynamoConfig = [
'region' => $config['region'],
'version' => 'latest',
'endpoint' => $config['endpoint'] ?? null,
];
if ($config['key'] && $config['secret']) {
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret', 'token']
);
}
$client = $this->newDynamodbClient($config);
return $this->repository(
new DynamoDbStore(
new DynamoDbClient($dynamoConfig),
$client,
$config['table'],
$config['attributes']['key'] ?? 'key',
$config['attributes']['value'] ?? 'value',
@@ -250,6 +240,28 @@ class CacheManager implements FactoryContract
);
}
/**
* Create new DynamoDb Client instance.
*
* @return DynamoDbClient
*/
protected function newDynamodbClient(array $config)
{
$dynamoConfig = [
'region' => $config['region'],
'version' => 'latest',
'endpoint' => $config['endpoint'] ?? null,
];
if (isset($config['key']) && isset($config['secret'])) {
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret', 'token']
);
}
return new DynamoDbClient($dynamoConfig);
}
/**
* Create a new cache repository with the given implementation.
*
@@ -258,15 +270,36 @@ class CacheManager implements FactoryContract
*/
public function repository(Store $store)
{
$repository = new Repository($store);
return tap(new Repository($store), function ($repository) {
$this->setEventDispatcher($repository);
});
}
if ($this->app->bound(DispatcherContract::class)) {
$repository->setEventDispatcher(
$this->app[DispatcherContract::class]
);
/**
* Set the event dispatcher on the given repository instance.
*
* @param \Illuminate\Cache\Repository $repository
* @return void
*/
protected function setEventDispatcher(Repository $repository)
{
if (! $this->app->bound(DispatcherContract::class)) {
return;
}
return $repository;
$repository->setEventDispatcher(
$this->app[DispatcherContract::class]
);
}
/**
* Re-set the event dispatcher on all resolved cache repositories.
*
* @return void
*/
public function refreshEventDispatcher()
{
array_map([$this, 'setEventDispatcher'], $this->stores);
}
/**

View File

@@ -2,8 +2,9 @@
namespace Illuminate\Cache;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\Cache\Adapter\Psr16Adapter;
class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
{
@@ -22,6 +23,10 @@ class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
return $app['cache']->driver();
});
$this->app->singleton('cache.psr6', function ($app) {
return new Psr16Adapter($app['cache.store']);
});
$this->app->singleton('memcached.connector', function () {
return new MemcachedConnector;
});
@@ -35,7 +40,7 @@ class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
public function provides()
{
return [
'cache', 'cache.store', 'memcached.connector',
'cache', 'cache.store', 'cache.psr6', 'memcached.connector',
];
}
}

View File

@@ -3,8 +3,8 @@
namespace Illuminate\Cache\Console;
use Illuminate\Console\Command;
use Illuminate\Support\Composer;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Composer;
class CacheTableCommand extends Command
{

View File

@@ -2,11 +2,11 @@
namespace Illuminate\Cache\Console;
use Illuminate\Console\Command;
use Illuminate\Cache\CacheManager;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class ClearCommand extends Command
{

View File

@@ -2,8 +2,8 @@
namespace Illuminate\Cache\Console;
use Illuminate\Console\Command;
use Illuminate\Cache\CacheManager;
use Illuminate\Console\Command;
class ForgetCommand extends Command
{

View File

@@ -1,8 +1,8 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCacheTable extends Migration
{

View File

@@ -4,11 +4,11 @@ namespace Illuminate\Cache;
use Closure;
use Exception;
use Illuminate\Support\Str;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\PostgresConnection;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
class DatabaseStore implements Store
{
@@ -87,7 +87,7 @@ class DatabaseStore implements Store
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -112,7 +112,7 @@ class DatabaseStore implements Store
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1)
@@ -126,7 +126,7 @@ class DatabaseStore implements Store
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1)
@@ -197,7 +197,7 @@ class DatabaseStore implements Store
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)

View File

@@ -42,13 +42,15 @@ class DynamoDbLock extends Lock
/**
* Release the lock.
*
* @return void
* @return bool
*/
public function release()
{
if ($this->isOwnedByCurrentProcess()) {
$this->dynamo->forget($this->name);
return $this->dynamo->forget($this->name);
}
return false;
}
/**

View File

@@ -2,16 +2,16 @@
namespace Illuminate\Cache;
use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
use Aws\DynamoDb\DynamoDbClient;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Cache\LockProvider;
use Aws\DynamoDb\Exception\DynamoDbException;
use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\Carbon;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
use RuntimeException;
class DynamoDbStore implements Store, LockProvider
class DynamoDbStore implements LockProvider, Store
{
use InteractsWithTime;
@@ -151,6 +151,7 @@ class DynamoDbStore implements Store, LockProvider
$now = Carbon::now();
return array_merge(collect(array_flip($keys))->map(function () {
//
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
if ($this->isExpired($response, $now)) {
$value = null;
@@ -390,7 +391,7 @@ class DynamoDbStore implements Store, LockProvider
*/
public function forever($key, $value)
{
return $this->put($key, $value, now()->addYears(5)->getTimestamp());
return $this->put($key, $value, Carbon::now()->addYears(5)->getTimestamp());
}
/**
@@ -442,6 +443,8 @@ class DynamoDbStore implements Store, LockProvider
* Remove all items from the cache.
*
* @return bool
*
* @throws \RuntimeException
*/
public function flush()
{
@@ -522,4 +525,14 @@ class DynamoDbStore implements Store, LockProvider
{
$this->prefix = ! empty($prefix) ? $prefix.':' : '';
}
/**
* Get the DynamoDb Client instance.
*
* @return DynamoDbClient
*/
public function getClient()
{
return $this->dynamo;
}
}

View File

@@ -25,17 +25,26 @@ class FileStore implements Store
*/
protected $directory;
/**
* Octal representation of the cache file permissions.
*
* @var int|null
*/
protected $filePermission;
/**
* Create a new file cache store instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $directory
* @param int|null $filePermission
* @return void
*/
public function __construct(Filesystem $files, $directory)
public function __construct(Filesystem $files, $directory, $filePermission = null)
{
$this->files = $files;
$this->directory = $directory;
$this->filePermission = $filePermission;
}
/**
@@ -53,7 +62,7 @@ class FileStore implements Store
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -65,7 +74,13 @@ class FileStore implements Store
$path, $this->expiration($seconds).serialize($value), true
);
return $result !== false && $result > 0;
if ($result !== false && $result > 0) {
$this->ensureFileHasCorrectPermissions($path);
return true;
}
return false;
}
/**
@@ -81,11 +96,27 @@ class FileStore implements Store
}
}
/**
* Ensure the cache file has the correct permissions.
*
* @param string $path
* @return void
*/
protected function ensureFileHasCorrectPermissions($path)
{
if (is_null($this->filePermission) ||
intval($this->files->chmod($path), 8) == $this->filePermission) {
return;
}
$this->files->chmod($path, $this->filePermission);
}
/**
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function increment($key, $value = 1)
@@ -101,7 +132,7 @@ class FileStore implements Store
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function decrement($key, $value = 1)
@@ -113,7 +144,7 @@ class FileStore implements Store
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)
@@ -148,7 +179,9 @@ class FileStore implements Store
}
foreach ($this->files->directories($this->directory) as $directory) {
if (! $this->files->deleteDirectory($directory)) {
$deleted = $this->files->deleteDirectory($directory);
if (! $deleted || $this->files->exists($directory)) {
return false;
}
}

View File

@@ -2,10 +2,10 @@
namespace Illuminate\Cache;
use Illuminate\Support\Str;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Cache\Lock as LockContract;
use Illuminate\Contracts\Cache\LockTimeoutException;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
abstract class Lock implements LockContract
{
@@ -61,7 +61,7 @@ abstract class Lock implements LockContract
/**
* Release the lock.
*
* @return void
* @return bool
*/
abstract public function release();
@@ -98,7 +98,7 @@ abstract class Lock implements LockContract
*
* @param int $seconds
* @param callable|null $callback
* @return bool
* @return mixed
*
* @throws \Illuminate\Contracts\Cache\LockTimeoutException
*/

View File

@@ -42,13 +42,15 @@ class MemcachedLock extends Lock
/**
* Release the lock.
*
* @return void
* @return bool
*/
public function release()
{
if ($this->isOwnedByCurrentProcess()) {
$this->memcached->delete($this->name);
return $this->memcached->delete($this->name);
}
return false;
}
/**

View File

@@ -2,10 +2,10 @@
namespace Illuminate\Cache;
use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Support\InteractsWithTime;
use Memcached;
use ReflectionMethod;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Cache\LockProvider;
class MemcachedStore extends TaggableStore implements LockProvider
{
@@ -36,7 +36,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Create a new Memcached store.
*
* @param \Memcached $memcached
* @param string $prefix
* @param string $prefix
* @return void
*/
public function __construct($memcached, $prefix = '')
@@ -96,7 +96,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -131,7 +131,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Store an item in the cache if the key doesn't exist.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -146,7 +146,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1)
@@ -158,7 +158,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1)
@@ -170,7 +170,7 @@ class MemcachedStore extends TaggableStore implements LockProvider
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)
@@ -181,9 +181,9 @@ class MemcachedStore extends TaggableStore implements LockProvider
/**
* Get a lock instance.
*
* @param string $name
* @param int $seconds
* @param string|null $owner
* @param string $name
* @param int $seconds
* @param string|null $owner
* @return \Illuminate\Contracts\Cache\Lock
*/
public function lock($name, $seconds = 0, $owner = null)

View File

@@ -6,13 +6,6 @@ class NullStore extends TaggableStore
{
use RetrievesMultipleKeys;
/**
* The array of stored values.
*
* @var array
*/
protected $storage = [];
/**
* Retrieve an item from the cache by key.
*
@@ -21,13 +14,14 @@ class NullStore extends TaggableStore
*/
public function get($key)
{
//
}
/**
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -40,7 +34,7 @@ class NullStore extends TaggableStore
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function increment($key, $value = 1)
@@ -52,7 +46,7 @@ class NullStore extends TaggableStore
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int|bool
*/
public function decrement($key, $value = 1)
@@ -64,7 +58,7 @@ class NullStore extends TaggableStore
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)

View File

@@ -2,8 +2,8 @@
namespace Illuminate\Cache;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Support\InteractsWithTime;
class RateLimiter
{
@@ -36,6 +36,8 @@ class RateLimiter
*/
public function tooManyAttempts($key, $maxAttempts)
{
$key = $this->cleanRateLimiterKey($key);
if ($this->attempts($key) >= $maxAttempts) {
if ($this->cache->has($key.':timer')) {
return true;
@@ -56,6 +58,8 @@ class RateLimiter
*/
public function hit($key, $decaySeconds = 60)
{
$key = $this->cleanRateLimiterKey($key);
$this->cache->add(
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
);
@@ -79,6 +83,8 @@ class RateLimiter
*/
public function attempts($key)
{
$key = $this->cleanRateLimiterKey($key);
return $this->cache->get($key, 0);
}
@@ -90,6 +96,8 @@ class RateLimiter
*/
public function resetAttempts($key)
{
$key = $this->cleanRateLimiterKey($key);
return $this->cache->forget($key);
}
@@ -102,6 +110,8 @@ class RateLimiter
*/
public function retriesLeft($key, $maxAttempts)
{
$key = $this->cleanRateLimiterKey($key);
$attempts = $this->attempts($key);
return $maxAttempts - $attempts;
@@ -115,6 +125,8 @@ class RateLimiter
*/
public function clear($key)
{
$key = $this->cleanRateLimiterKey($key);
$this->resetAttempts($key);
$this->cache->forget($key.':timer');
@@ -128,6 +140,19 @@ class RateLimiter
*/
public function availableIn($key)
{
$key = $this->cleanRateLimiterKey($key);
return $this->cache->get($key.':timer') - $this->currentTime();
}
/**
* Clean the rate limiter key from unicode characters.
*
* @param string $key
* @return string
*/
public function cleanRateLimiterKey($key)
{
return preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities($key));
}
}

View File

@@ -34,23 +34,21 @@ class RedisLock extends Lock
*/
public function acquire()
{
$result = $this->redis->setnx($this->name, $this->owner);
if ($result === 1 && $this->seconds > 0) {
$this->redis->expire($this->name, $this->seconds);
if ($this->seconds > 0) {
return $this->redis->set($this->name, $this->owner, 'EX', $this->seconds, 'NX') == true;
} else {
return $this->redis->setnx($this->name, $this->owner) === 1;
}
return $result === 1;
}
/**
* Release the lock.
*
* @return void
* @return bool
*/
public function release()
{
$this->redis->eval(LuaScripts::releaseLock(), 1, $this->name, $this->owner);
return (bool) $this->redis->eval(LuaScripts::releaseLock(), 1, $this->name, $this->owner);
}
/**

View File

@@ -83,7 +83,7 @@ class RedisStore extends TaggableStore implements LockProvider
* Store an item in the cache for a given number of seconds.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -122,7 +122,7 @@ class RedisStore extends TaggableStore implements LockProvider
* Store an item in the cache if the key doesn't exist.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param int $seconds
* @return bool
*/
@@ -139,7 +139,7 @@ class RedisStore extends TaggableStore implements LockProvider
* Increment the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function increment($key, $value = 1)
@@ -151,7 +151,7 @@ class RedisStore extends TaggableStore implements LockProvider
* Decrement the value of an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return int
*/
public function decrement($key, $value = 1)
@@ -163,7 +163,7 @@ class RedisStore extends TaggableStore implements LockProvider
* Store an item in the cache indefinitely.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return bool
*/
public function forever($key, $value)
@@ -174,9 +174,9 @@ class RedisStore extends TaggableStore implements LockProvider
/**
* Get a lock instance.
*
* @param string $name
* @param int $seconds
* @param string|null $owner
* @param string $name
* @param int $seconds
* @param string|null $owner
* @return \Illuminate\Contracts\Cache\Lock
*/
public function lock($name, $seconds = 0, $owner = null)
@@ -235,7 +235,7 @@ class RedisStore extends TaggableStore implements LockProvider
/**
* Get the Redis connection instance.
*
* @return \Predis\ClientInterface
* @return \Illuminate\Redis\Connections\Connection
*/
public function connection()
{
@@ -292,7 +292,7 @@ class RedisStore extends TaggableStore implements LockProvider
*/
protected function serialize($value)
{
return is_numeric($value) ? $value : serialize($value);
return is_numeric($value) && ! in_array($value, [INF, -INF]) && ! is_nan($value) ? $value : serialize($value);
}
/**

View File

@@ -21,7 +21,7 @@ class RedisTaggedCache extends TaggedCache
* Store an item in the cache.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @param \DateTimeInterface|\DateInterval|int|null $ttl
* @return bool
*/
@@ -179,7 +179,7 @@ class RedisTaggedCache extends TaggedCache
if (count($values) > 0) {
foreach (array_chunk($values, 1000) as $valuesChunk) {
call_user_func_array([$this->store->connection(), 'del'], $valuesChunk);
$this->store->connection()->del(...$valuesChunk);
}
}
}

View File

@@ -2,25 +2,25 @@
namespace Illuminate\Cache;
use Closure;
use ArrayAccess;
use DateTimeInterface;
use BadMethodCallException;
use Illuminate\Support\Carbon;
use Closure;
use DateTimeInterface;
use Illuminate\Cache\Events\CacheHit;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Cache\Events\KeyWritten;
use Illuminate\Cache\Events\CacheMissed;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Cache\Events\KeyForgotten;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Cache\Events\KeyWritten;
use Illuminate\Contracts\Cache\Repository as CacheContract;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Carbon;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Traits\Macroable;
/**
* @mixin \Illuminate\Contracts\Cache\Store
*/
class Repository implements CacheContract, ArrayAccess
class Repository implements ArrayAccess, CacheContract
{
use InteractsWithTime;
use Macroable {
@@ -504,7 +504,7 @@ class Repository implements CacheContract, ArrayAccess
/**
* Get the default cache time.
*
* @return int
* @return int|null
*/
public function getDefaultCacheTime()
{
@@ -547,6 +547,16 @@ class Repository implements CacheContract, ArrayAccess
}
}
/**
* Get the event dispatcher instance.
*
* @return \Illuminate\Contracts\Events\Dispatcher
*/
public function getEventDispatcher()
{
return $this->events;
}
/**
* Set the event dispatcher instance.
*
@@ -584,7 +594,7 @@ class Repository implements CacheContract, ArrayAccess
* Store an item in the cache for the default time.
*
* @param string $key
* @param mixed $value
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)

View File

@@ -14,9 +14,9 @@
}
],
"require": {
"php": "^7.1.3",
"illuminate/contracts": "5.8.*",
"illuminate/support": "5.8.*"
"php": "^7.2.5|^8.0",
"illuminate/contracts": "^6.0",
"illuminate/support": "^6.0"
},
"autoload": {
"psr-4": {
@@ -25,13 +25,15 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.8-dev"
"dev-master": "6.x-dev"
}
},
"suggest": {
"illuminate/database": "Required to use the database cache driver (5.8.*).",
"illuminate/filesystem": "Required to use the file cache driver (5.8.*).",
"illuminate/redis": "Required to use the redis cache driver (5.8.*)."
"ext-memcached": "Required to use the memcache cache driver.",
"illuminate/database": "Required to use the database cache driver (^6.0).",
"illuminate/filesystem": "Required to use the file cache driver (^6.0).",
"illuminate/redis": "Required to use the redis cache driver (^6.0).",
"symfony/cache": "Required to PSR-6 cache bridge (^4.3.4)."
},
"config": {
"sort-packages": true