PHP Interface bandwidthThrottle\tokenBucket\storage\Storage

The storage determines the scope for the token bucket. It therefore implements one of the *Scope marker interfaces: - {@link RequestScope}: The bucket is shared only within one request. - {@link SessionScope}: The bucket is shared between requests of one session. - {@link GlobalScope}: The bucket is shared among all processes.
Author: Markus Malkusch ([email protected])
Show file Open project: bandwidth-throttle/token-bucket

Public Methods

Method Description
bootstrap ( double $microtime ) Bootstraps the storage.
getMicrotime ( ) : double Returns the stored timestamp.
getMutex ( ) : Mutex Returns the Mutex for this storage.
isBootstrapped ( ) : boolean Returns if the storage was already bootstrapped.
remove ( ) Removes the storage.
setMicrotime ( double $microtime ) Stores a timestamp.

Method Details

bootstrap() public method

Bootstraps the storage.
public bootstrap ( double $microtime )
$microtime double The timestamp.

getMicrotime() public method

Returns the stored timestamp.
public getMicrotime ( ) : double
return double The timestamp.

getMutex() public method

Returns the Mutex for this storage.
public getMutex ( ) : Mutex
return malkusch\lock\mutex\Mutex The mutex.

isBootstrapped() public method

Returns if the storage was already bootstrapped.
public isBootstrapped ( ) : boolean
return boolean True if the storage was already bootstrapped.

remove() public method

After a storage was removed you should not use that object anymore. The only defined methods after that operations are isBootstrapped() and bootstrap(). A call to bootstrap() results in a defined object again.
public remove ( )

setMicrotime() public method

Stores a timestamp.
public setMicrotime ( double $microtime )
$microtime double The timestamp.