0 follower

Interface Yiisoft\Yii\RateLimiter\Storage\StorageInterface

Implemented byYiisoft\Yii\RateLimiter\Storage\ApcuStorage, Yiisoft\Yii\RateLimiter\Storage\SimpleCacheStorage

Counter storage.

Public Methods

Hide inherited methods

Method Description Defined By
get() Fetches a counter value from the storage. Yiisoft\Yii\RateLimiter\Storage\StorageInterface
saveCompareAndSwap() Compares the old value of key to the value which was saved in the store. Yiisoft\Yii\RateLimiter\Storage\StorageInterface
saveIfNotExists() Saves the value of key only if it was not already saved in the store. Yiisoft\Yii\RateLimiter\Storage\StorageInterface

Method Details

Hide inherited methods

get() public abstract method

Fetches a counter value from the storage.

public abstract float|null get ( string $key )
$key string

The unique key of this counter in the storage.

return float|null

It returns float if a value was saved. Otherwise, it returns null

                public function get(string $key): ?float;

            
saveCompareAndSwap() public abstract method

Compares the old value of key to the value which was saved in the store.

If it matches, method saves it to the new value and returns true. Otherwise, it returns false. If the key does not exist in the storage, it returns false. If the storage supports expiring keys, the key will expire after the provided TTL.

public abstract boolean saveCompareAndSwap ( string $key, float $oldValue, float $newValue, integer $ttl )
$key string

The ID of the counter to store.

$oldValue float

The old value of the counter.

$newValue float

The new value of the counter.

$ttl integer

The TTL value of this counter.

                public function saveCompareAndSwap(string $key, float $oldValue, float $newValue, int $ttl): bool;

            
saveIfNotExists() public abstract method

Saves the value of key only if it was not already saved in the store.

It returns false if a value was saved. Otherwise, it returns true and saves the value. If the storage supports expiring keys, the key will expire after the provided TTL.

public abstract boolean saveIfNotExists ( string $key, float $value, integer $ttl )
$key string

The ID of the counter to store.

$value float

The value of the counter.

$ttl integer

The TTL value of this counter.

                public function saveIfNotExists(string $key, float $value, int $ttl): bool;