Class NFileStorage


NCache file storage.

NObject
   |
   --NFileStorage

Implements interfaces:

Direct Known Sub-classes:

Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Caching/FileStorage.php (line 35)
Public Method Summary
NFileStorage
__construct ($dir)
bool
clean ($conds)
Removes items from the cache by conditions & garbage collector.
mixed|NULL
read (string $key)
Read from cache.
bool
remove (string $key)
Removes item from the cache.
bool
write (string $key, mixed $data, $dp)
Writes item into the cache.
Protected Method Summary
protected string
getCacheFile (string $key)
Returns file name.
protected mixed
readData (array $meta)
Reads cache data from disk and closes cache file handle.
protected array|NULL
readMeta (string $file, int $lock)
Reads cache data from disk.
Methods Inherited From NObject
extensionMethod(), getClass(), getReflection(), __call(), __callStatic(), __get(), __isset(), __set(), __unset()
Constant Summary
string FILE 'file'

line 62

additional cache structure
string HANDLE 'handle'

line 63

additional cache structure
string META_CALLBACKS 'callbacks'

line 58

internal cache file structure
string META_DELTA 'delta'

line 55

internal cache file structure
string META_EXPIRE 'expire'

line 54

internal cache file structure
int META_HEADER_LEN 28

line 49

internal cache file structure
string META_ITEMS 'di'

line 56

internal cache file structure
string META_PRIORITY 'priority'

line 53

internal cache file structure
string META_SERIALIZED 'serialized'

line 52

internal cache file structure
string META_TAGS 'tags'

line 57

internal cache file structure
string META_TIME 'time'

line 51

internal cache file structure
Variable Summary
static float $gcProbability 0.001

line 68

probability that the clean() routine is started
static bool $useDirectories

line 71


Method Details

line 81

__construct

public NFileStorage __construct ($dir)

Input
$dir
Output
NFileStorage  

line 275

clean

public bool clean ($conds)

Removes items from the cache by conditions & garbage collector.

Implementation of:

Input
$conds conditions
Output
bool TRUE if no problem

line 379

getCacheFile

protected string getCacheFile (string $key)

Returns file name.

Overridden in child classes as:

Input
string $key
Output
string  

line 116

read

public mixed|NULL read (string $key)

Read from cache.

Implementation of:

Input
string $key key
Output
mixed|NULL  

line 360

readData

protected mixed readData (array $meta)

Reads cache data from disk and closes cache file handle.

Overridden in child classes as:

Input
array $meta
Output
mixed  

line 329

readMeta

protected array|NULL readMeta (string $file, int $lock)

Reads cache data from disk.

Input
string $file file path
int $lock lock mode
Output
array|NULL  

line 258

remove

public bool remove (string $key)

Removes item from the cache.

Implementation of:

Input
string $key key
Output
bool TRUE if no problem

line 174

write

public bool write (string $key, mixed $data, $dp)

Writes item into the cache.

Implementation of:

Input
string $key key
mixed $data data
$dp dependencies
Output
bool TRUE if no problem