Class ArrayCache
A cache service that stored data in PHP array
-
Wei\Base
-
Wei\BaseCache
-
Wei\ArrayCache
Methods summary
public
mixed
|
#
get( string $key, integer $expire = null, callable $fn = null )
Retrieve an item
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
|
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
|
public
boolean
|
#
remove( string $key )
Remove an item
Parameters
Returns
boolean
|
public
boolean
|
#
exists( string $key )
Check if an item is exists
Check if an item is exists
Parameters
Returns
boolean
|
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
|
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
|
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
boolean
|
#
clear( )
Clear all items
Returns
boolean
|
Properties summary
protected
array
|
$data
The array to store cache items
The array to store cache items
|
|