Final Class Yiisoft\Yii\RateLimiter\Storage\SimpleCacheStorage
| Inheritance | Yiisoft\Yii\RateLimiter\Storage\SimpleCacheStorage |
|---|---|
| Implements | Yiisoft\Yii\RateLimiter\Storage\StorageInterface |
Public Methods
Method Details
| public __construct( \Psr\SimpleCache\CacheInterface $cache ): mixed | ||
| $cache | \Psr\SimpleCache\CacheInterface | |
public function __construct(private CacheInterface $cache)
{
}
| public get( string $key ): float|null | ||
| $key | string | |
public function get(string $key): ?float
{
/** @psalm-suppress MixedAssignment */
$value = $this->cache->get($key);
return (is_int($value) || is_float($value)) ? (float) $value : null;
}
| public saveCompareAndSwap( string $key, float $oldValue, float $newValue, integer $ttl ): boolean | ||
| $key | string | |
| $oldValue | float | |
| $newValue | float | |
| $ttl | integer | |
public function saveCompareAndSwap(string $key, float $oldValue, float $newValue, int $ttl): bool
{
return $this->cache->set($key, $newValue, $ttl);
}
Signup or Login in order to comment.