Final Class Yiisoft\Yii\RateLimiter\Storage\SimpleCacheStorage
| Inheritance | Yiisoft\Yii\RateLimiter\Storage\SimpleCacheStorage |
|---|---|
| Implements | Yiisoft\Yii\RateLimiter\Storage\StorageInterface |
Public Methods
Method Details
| public mixed __construct ( \Psr\SimpleCache\CacheInterface $cache ) | ||
| $cache | \Psr\SimpleCache\CacheInterface | |
public function __construct(private CacheInterface $cache)
{
}
| public float|null get ( string $key ) | ||
| $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 boolean saveCompareAndSwap ( string $key, float $oldValue, float $newValue, integer $ttl ) | ||
| $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.