Methods summary
public
mixed
|
#
__invoke( string $key, mixed $value = null, integer $expire = 0 )
Retrieve or store an item
Retrieve or store an item
Parameters
- $key
- The name of item
- $value
- The value of item
- $expire
- The expire seconds, defaults to 0, means never expired
Returns
mixed
|
abstract public
mixed
|
#
get( string $key, integer $expire = null, callable $fn = null )
Retrieve an item
$cache = wei()->cache;
$cache->get('key');
$cache->get('key', function($wei){ return 'value';
});
$cache->get('key', 10, function($wei){ return 'value';
});
Parameters
- $key
- The name of item
- $expire
- The expire seconds of callback return value
- $fn
- The callback to execute when cache not found
Returns
mixed
Throws
RuntimeException When set cache return false
|
protected
mixed
|
#
processGetResult( string $key, mixed $result, integer $expire, callable $fn )
Store data to cache when data is not false and callback is provided
Store data to cache when data is not false and callback is provided
Parameters
Returns
mixed
Throws
RuntimeException
InvalidArgumentException
|
abstract public
boolean
|
#
set( string $key, mixed $value, integer $expire = 0 )
Store an item
Parameters
- $key
- The name of item
- $value
- The value of item
- $expire
- The expire seconds, defaults to 0, means never expired
Returns
boolean
|
abstract public
boolean
|
#
remove( string $key )
Remove an item
Parameters
Returns
boolean
|
abstract public
boolean
|
#
exists( string $key )
Check if an item is exists
Check if an item is exists
Parameters
Returns
boolean
|
abstract public
boolean
|
#
add( string $key, mixed $value, integer $expire = 0 )
Add an item
Parameters
- $key
- The name of item
- $value
- The value of item
- $expire
- The expire seconds, defaults to 0, means never expired
Returns
boolean
|
abstract public
boolean
|
#
replace( string $key, mixed $value, integer $expire = 0 )
Replace an existing item
Parameters
- $key
- The name of item
- $value
- The value of item
- $expire
- The expire seconds, defaults to 0, means never expired
Returns
boolean
|
abstract public
integer|false
|
#
incr( string $key, integer $offset = 1 )
Increment an item
Parameters
- $key
- The name of item
- $offset
- The value to increased
Returns
integer|false Returns the new value on success, or false on failure
|
public
integer|false
|
#
decr( string $key, integer $offset = 1 )
Decrement an item
Parameters
- $key
- The name of item
- $offset
- The value to be decreased
Returns
integer|false Returns the new value on success, or false on failure
|
public
array
|
#
getMulti( array $keys )
Retrieve multiple items
Parameters
Returns
array
|
public
array
|
#
setMulti( array $keys, integer $expire = 0 )
Store multiple items
Parameters
- $keys
- The name of items
- $expire
Returns
array
|
public
mixed
|
#
getFileContent( string $file, callable $fn )
Use the file modify time as cache key to store an item from a callback
Use the file modify time as cache key to store an item from a callback
Parameters
- $file
- The path of file
- $fn
- The callback to get and parse file content
Returns
mixed
|
public
string
|
|
public
|
#
setNamespace( string $namespace )
Set the cache key prefix
Parameters
Returns
$this
|
abstract public
boolean
|
#
clear( )
Clear all items
Returns
boolean
|