Class Vars
Accessor for the variables stored as files in the "/repository/var"
directory.
-
ICanBoogie\Vars
implements
ArrayAccess,
IteratorAggregate
Methods summary
public
|
#
__construct( string $path )
Constructor.
Parameters
- $path
string $path Absolute path to the vars directory.
Throws
|
public
|
|
public
boolean
|
#
offsetExists( string $name )
Checks if the var exists.
Checks if the var exists.
Parameters
- $name
string $name Name of the variable.
Returns
boolean true if the var exists, false otherwise.
See
Implementation of
|
public
|
#
offsetUnset( mixed $name )
Deletes a var.
See
Implementation of
|
public
|
|
public
|
#
store( string $key, mixed $value, integer $ttl = 0 )
Cache a variable in the repository.
Cache a variable in the repository.
If the value is an array or a string it is serialized and prepended with a
magic identifier. This magic identifier is used to recognized previously
serialized values when they are read back.
Parameters
- $key
string $key The key used to identify the value. Keys are unique, so storing a second
value with the same key will overwrite the previous value.
- $value
mixed $value The value to store for the key.
- $ttl
integer $ttl The time to live in seconds for the stored value. If no _ttl_ is supplied
(or if the _tll_ is __0__), the value will persist until it is removed from the
cache manually or otherwise fails to exist in the cache.
Throws
|
public
mixed
|
#
retrieve( string $name, mixed $default = null )
Returns the value of variable.
Returns the value of variable.
If the value is marked with the magic identifier it is not serialized.
Parameters
- $name
string $name
- $default
mixed $default The value returned if the variable does not exists. Defaults to null.
Returns
mixed
|
public
ICanBoogie\VarsIterator
|
#
getIterator( )
Returns a directory iterator for the variables.
Returns a directory iterator for the variables.
Returns
See
Implementation of
|
public
ICanBoogie\VarsIterator
|
#
matching( string $regex )
Returns a file iterator for variables matching a regex.
Returns a file iterator for variables matching a regex.
Parameters
Returns
|
Magic methods summary
Constants summary
string |
MAGIC
|
"VAR\0SLZ\0" |
#
Magic pattern used to recognized automatically serialized values.
Magic pattern used to recognized automatically serialized values.
|
integer |
MAGIC_LENGTH
|
8 |
|
Properties summary
protected
string
|
$path
|
#
Absolute path to the vars directory.
Absolute path to the vars directory.
|