PHP Class MatthiasMullie\Scrapbook\Adapters\Flysystem

Flysystem doesn't allow locking files, though. To guarantee interference from other processes, we'll create separate lock-files to flag a cache key in use.
Author: Matthias Mullie ([email protected])
Inheritance: implements MatthiasMullie\Scrapbook\KeyValueStore
Show file Open project: matthiasmullie/scrapbook

Protected Properties

Property Type Description
$filesystem League\Flysystem\Filesystem

Public Methods

Method Description
__construct ( League\Flysystem\Filesystem $filesystem )
add ( $key, $value, $expire )
cas ( $token, $key, $value, $expire )
decrement ( $key, $offset = 1, $initial, $expire )
delete ( $key )
deleteMulti ( array $keys )
flush ( )
get ( $key, &$token = null )
getMulti ( array $keys, array &$tokens = null )
increment ( $key, $offset = 1, $initial, $expire )
replace ( $key, $value, $expire )
set ( $key, $value, $expire )
setMulti ( array $items, $expire )
touch ( $key, $expire )

Protected Methods

Method Description
doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation split up (increment won't accept negative values).
exists ( string $key ) : boolean
lock ( string $key ) : boolean Obtain a lock for a given key.
normalizeTime ( integer $time ) : integer Times can be: * relative (in seconds) to current time, within 30 days * absolute unix timestamp * 0, for infinity.
path ( string $key ) : string
read ( string $key ) : boolean | array Fetch stored data from cache file.
unlock ( string $key ) : boolean Release the lock for a given key.
wrap ( string $value, integer $expire ) : string Build value, token & expiration time to be stored in cache file.

Method Details

__construct() public method

public __construct ( League\Flysystem\Filesystem $filesystem )
$filesystem League\Flysystem\Filesystem

add() public method

public add ( $key, $value, $expire )

cas() public method

public cas ( $token, $key, $value, $expire )

decrement() public method

public decrement ( $key, $offset = 1, $initial, $expire )

delete() public method

public delete ( $key )

deleteMulti() public method

public deleteMulti ( array $keys )
$keys array

doIncrement() protected method

Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation split up (increment won't accept negative values).
protected doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean
$key string
$offset integer
$initial integer
$expire integer
return integer | boolean

exists() protected method

protected exists ( string $key ) : boolean
$key string
return boolean

flush() public method

public flush ( )

get() public method

public get ( $key, &$token = null )

getMulti() public method

public getMulti ( array $keys, array &$tokens = null )
$keys array
$tokens array

increment() public method

public increment ( $key, $offset = 1, $initial, $expire )

lock() protected method

It'll try to get a lock for a couple of times, but ultimately give up if no lock can be obtained in a reasonable time.
protected lock ( string $key ) : boolean
$key string
return boolean

normalizeTime() protected method

The first case (relative time) will be normalized into a fixed absolute timestamp.
protected normalizeTime ( integer $time ) : integer
$time integer
return integer

path() protected method

protected path ( string $key ) : string
$key string
return string

read() protected method

Fetch stored data from cache file.
protected read ( string $key ) : boolean | array
$key string
return boolean | array

replace() public method

public replace ( $key, $value, $expire )

set() public method

public set ( $key, $value, $expire )

setMulti() public method

public setMulti ( array $items, $expire )
$items array

touch() public method

public touch ( $key, $expire )

unlock() protected method

Release the lock for a given key.
protected unlock ( string $key ) : boolean
$key string
return boolean

wrap() protected method

Build value, token & expiration time to be stored in cache file.
protected wrap ( string $value, integer $expire ) : string
$value string
$expire integer
return string

Property Details

$filesystem protected property

protected Filesystem,League\Flysystem $filesystem
return League\Flysystem\Filesystem