Class FileStorage
A storage using the file system.
-
ICanBoogie\Storage\FileStorage
implements
ArrayAccess,
IteratorAggregate,
ICanBoogie\Storage\StorageInterface
uses
ICanBoogie\Storage\ArrayAccessTrait
Methods summary
public
__construct( string $path
)
Constructor.
Parameters
$path
- Absolute path to the storage directory.
public
store( string $key
, mixed $value
, string $ttl
= 0 )
Parameters
$key
Store the variable using this name. keys are cache-unique, so storing
a second value with the same key will overwrite the original value.
$value
- The value to store.
$ttl
Time To Live; store value
in the cache for ttl
seconds. After the
ttl
has passed, the stored value won't be available for the next request. If no ttl
is
supplied (or if the ttl
is empty), the value will persist until it is removed from the
cache manually, or otherwise fails to exist in the cache.
Throws
Exception
when a file operation fails.
Inheritdoc
Implementation of
public
retrieve( mixed $name
, $default
= null )
: mixed|null
Parameters
$name
- $default The value returned if the key does not exists. Defaults to
null
.
$default
Returns
mixed|null
The value associated with the key, or null
if the key doesn't exists.
Inheritdoc
Implementation of
public
eliminate( string $name
)
Parameters
Inheritdoc
Implementation of
public
exists( string $name
)
: boolean
Parameters
Returns
boolean
true
if the key exists, false
otherwise.
Inheritdoc
Implementation of
public
clear( void )
Clears the cache.
Implementation of
public
getIterator( void )
: ICanBoogie\Storage\FileStorageIterator
Returns an iterator for the storage.
Returns an iterator for the storage.
Returns
Implementation of
IteratorAggregate::getIterator()
public
matching( string $regex
)
: ICanBoogie\Storage\FileStorageIterator
Returns an iterator for the keys matching a specified regex.
Returns an iterator for the keys matching a specified regex.
Parameters
Returns
public
check_writable( void )
: boolean
Checks whether the storage directory is writable.
Checks whether the storage directory is writable.
Returns
boolean
Throws
Exception
when the storage directory is not writable.
Methods inherited from ArrayAccess
offsetExists()
,
offsetGet()
,
offsetSet()
,
offsetUnset()
offsetExists()
,
offsetGet()
,
offsetSet()
,
offsetUnset()
Constants summary
MAGIC
: string
Magic pattern used to recognized automatically serialized values.
Magic pattern used to recognized automatically serialized values.
"VAR\0SLZ\0"
Properties summary
protected
$path
: string
Absolute path to the storage directory.
Absolute path to the storage directory.