xpdo/cache/xpdocachemanager.class.php

Classes 
package
xpdo
subpackage
cache
Classes
xPDOCacheManager
xPDOCache
xPDOFileCache

Description

Classes implementing a default cache implementation for xPDO.

\xPDOCache

package
xpdo
subpackage
cache
Properties
$initialized
$key
$options
$xpdo
Methods
__construct
add
delete
flush
get
getCacheKey
getOption
isInitialized
replace
set

Description

An abstract class that defines the methods a cache provider must implement.

Properties

$initialized

 $initialized = 'false'

Details

visibility
protected
default
false
final
false
static
false

$key

 $key = ''

Details

visibility
protected
default
final
false
static
false

$options

 $options = 'array'

Details

visibility
protected
default
array
final
false
static
false

$xpdo

 $xpdo = 'null'

Details

visibility
public
default
null
final
false
static
false

Methods

__construct

__construct(  $xpdo,  $options = array ) :
Arguments
$xpdo
$options
Details
visibility
public
final
false
static
false

add

add( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Adds a value to the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false
access
public

delete

delete( string $key, array $options = array ) : boolean

Deletes a value from the cache.

Arguments
$key
string
A unique key identifying the item being deleted.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false
access
public

flush

flush( array $options = array ) : boolean

Flush all values from the cache.

Arguments
$options
array
Additional options for the operation.
Output
boolean
True if successful.
Details
visibility
public
final
false
static
false
access
public

get

get( string $key, array $options = array ) : mixed

Gets a value from the cache.

Arguments
$key
string
A unique key identifying the item to fetch.
$options
array
Additional options for the operation.
Output
mixed
The value retrieved from the cache.
Details
visibility
public
final
false
static
false
access
public

getCacheKey

getCacheKey( string $key, array $options = array ) : string

Get the actual cache key the implementation will use.

Arguments
$key
string
The identifier the application uses.
$options
array
Additional options for the operation.
Output
string
The identifier with any implementation specific prefixes or other transformations applied.
Details
visibility
public
final
false
static
false

getOption

getOption( string $key, array $options = array, mixed $default = null ) : mixed

Get an option from supplied options, the cache options, or the xpdo config.

Arguments
$key
string
Unique identifier for the option.
$options
array
A set of explicit options to override those from xPDO or the xPDOCache implementation.
$default
mixed
An optional default value to return if no value is found.
Output
mixed
The value of the option.
Details
visibility
public
final
false
static
false

isInitialized

isInitialized( ) : boolean

Indicates if this xPDOCache instance has been properly initialized.

Output
boolean
true if the implementation was initialized successfully.
Details
visibility
public
final
false
static
false

replace

replace( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Replaces a value in the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false
access
public

set

set( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Sets a value in the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false
access
public

\xPDOCacheManager

package
xpdo
subpackage
cache
Constants
CACHE_DIR
CACHE_JSON
CACHE_PHP
CACHE_SERIALIZE
LOG_DIR
Properties
$_umask
$caches
$options
$xpdo
Methods
__construct
add
clean
copyFile
copyTree
delete
deleteTree
endsWith
escapeSingleQuotes
generateObject
get
getCachePath
getCacheProvider
getFilePermissions
getFolderPermissions
getOption
matches
refresh
replace
set
writeFile
writeTree

Description

The default cache manager implementation for xPDO.

Constants

CACHE_PHP

 CACHE_PHP = '0'

Details

value
0

CACHE_JSON

 CACHE_JSON = '1'

Details

value
1

CACHE_SERIALIZE

 CACHE_SERIALIZE = '2'

Details

value
2

CACHE_DIR

 CACHE_DIR = 'objects/'

Details

value
objects/

LOG_DIR

 LOG_DIR = 'logs/'

Details

value
logs/

Properties

$_umask

 $_umask = 'null'

Details

visibility
protected
default
null
final
false
static
false

$caches

 $caches = 'array'

Details

visibility
protected
default
array
final
false
static
false

$options

 $options = 'array'

Details

visibility
protected
default
array
final
false
static
false

$xpdo

 $xpdo = 'null'

Details

visibility
protected
default
null
final
false
static
false

Methods

__construct

__construct(  $xpdo,  $options = array ) :
Arguments
$xpdo
$options
Details
visibility
public
final
false
static
false

add

add( string $key, mixed $var, integer $lifetime = 0, array $options = array ) :

Add a key-value pair to a cache provider if it does not already exist.

Arguments
$key
string
A unique key identifying the item being stored.
$var
mixed
& $var A reference to the PHP variable representing the item.
$lifetime
integer
Seconds the item will be valid in cache.
$options
array
Additional options for the cache add operation.
Details
visibility
public
final
false
static
false

clean

clean( array $options = array ) : boolean

Flush the contents of a cache provider.

Arguments
$options
array
Additional options for the cache flush.
Output
boolean
True if the flush was successful.
Details
visibility
public
final
false
static
false
access
public

copyFile

copyFile( string $source, string $target, array $options = array ) : boolean|array

Copies a file from a source file to a target directory.

Arguments
$source
string
The absolute path of the source file.
$target
string
The absolute path of the target destination directory.
$options
array
An array of options for this function.
Output
boolean|array
Returns true if the copy operation was successful, or a single element array with filename as key and stat results of the successfully copied file as a result.
Details
visibility
public
final
false
static
false
access
public

copyTree

copyTree( string $source, string $target, array $options = array ) : array|boolean

Recursively copies a directory tree from a source directory to a target directory.

Arguments
$source
string
The absolute path of the source directory.
$target
string
The absolute path of the target destination directory.
$options
array
An array of options for this function.
Output
array|boolean
Returns an array of all files and folders that were copied or false.
Details
visibility
public
final
false
static
false
access
public

delete

delete( string $key, array $options = array ) : boolean

Delete a key-value pair from a cache provider.

Arguments
$key
string
A unique key identifying the item being deleted.
$options
array
Additional options for the cache deletion.
Output
boolean
True if the deletion was successful.
Details
visibility
public
final
false
static
false
access
public

deleteTree

deleteTree( string $dirname, array $options = array ) : boolean

Recursively deletes a directory tree of files.

Arguments
$dirname
string
An absolute path to the source directory to delete.
$options
array
An array of options for this function.
Output
boolean
Returns true if the deletion was successful.
Details
visibility
public
final
false
static
false
access
public

endsWith

endsWith( string $string, string|array $pattern ) : boolean

Sees if a string ends with a specific pattern or set of patterns.

Arguments
$string
string
The string to check.
$pattern
stringarray
The pattern or an array of patterns to check against.
Output
boolean
True if the string ends with the pattern or any of the patterns provided.
Details
visibility
public
final
false
static
false
access
public

escapeSingleQuotes

escapeSingleQuotes( string $s ) : string

Escapes all single quotes in a string

Arguments
$s
string
The string to escape single quotes in.
Output
string
The string with single quotes escaped.
Details
visibility
public
final
false
static
false
access
public

generateObject

generateObject( \xPDOObject $obj, string $objName, boolean $generateObjVars = false, boolean $generateRelated = false, string $objRef = this->xpdo, boolean $format = xPDOCacheManager ) : string

Generate a PHP executable representation of an xPDOObject.

Arguments
$obj
\xPDOObject
An xPDOObject to generate the cache file for
$objName
string
The name of the xPDOObject
$generateObjVars
boolean
If true, will also generate maps for all object variables. Defaults to false.
$generateRelated
boolean
If true, will also generate maps for all related objects. Defaults to false.
$objRef
string
The reference to the xPDO instance, in string format.
$format
boolean
The format to cache in. Defaults to xPDOCacheManager::CACHE_PHP, which is set to cache in executable PHP format.
Output
string
The source map file, in string format.
Details
visibility
public
final
false
static
false
access
public
todo
Complete $generateRelated functionality.
todo
Add stdObject support.

get

get( string $key, array $options = array ) : mixed

Get a value from a cache provider by key.

Arguments
$key
string
A unique key identifying the item being retrieved.
$options
array
Additional options for the cache retrieval.
Output
mixed
The value of the object cache key
Details
visibility
public
final
false
static
false
access
public

getCachePath

getCachePath( ) : string

Get the absolute path to a writable directory for storing files.

Output
string
The absolute path of the xPDO cache directory.
Details
visibility
public
final
false
static
false
access
public

getCacheProvider

getCacheProvider(  $key,  $options = array ) :

Get an instance of a provider which implements the xPDOCache interface.

Arguments
$key
$options
Details
visibility
public
final
false
static
false

getFilePermissions

getFilePermissions( ) : integer

Get default file permissions based on umask

Output
integer
The default file permissions.
Details
visibility
public
final
false
static
false

getFolderPermissions

getFolderPermissions( ) : integer

Get default folder permissions based on umask

Output
integer
The default folder permissions.
Details
visibility
public
final
false
static
false

getOption

getOption( string $key, array $options = array, mixed $default = null ) : mixed

Get an option from supplied options, the cacheManager options, or xpdo itself.

Arguments
$key
string
Unique identifier for the option.
$options
array
A set of explicit options to override those from xPDO or the xPDOCacheManager implementation.
$default
mixed
An optional default value to return if no value is found.
Output
mixed
The value of the option.
Details
visibility
public
final
false
static
false

matches

matches( string $string, string|array $pattern ) : boolean

Sees if a string matches a specific pattern or set of patterns.

Arguments
$string
string
The string to check.
$pattern
stringarray
The pattern or an array of patterns to check against.
Output
boolean
True if the string matched the pattern or any of the patterns provided.
Details
visibility
public
final
false
static
false
access
public

refresh

refresh( array $providers = array, array $results = array ) : array

Refresh specific or all cache providers.

The default behavior is to call clean() with the provided options

Arguments
$providers
array
An associative array with keys representing the cache provider key and the value an array of options.
$results
array
&$results An associative array for collecting results for each provider.
Output
array
An array of results for each provider that is refreshed.
Details
visibility
public
final
false
static
false

replace

replace( string $key, mixed $var, integer $lifetime = 0, array $options = array ) : boolean

Replace a key-value pair in in a cache provider.

Arguments
$key
string
A unique key identifying the item being replaced.
$var
mixed
& $var A reference to the PHP variable representing the item.
$lifetime
integer
Seconds the item will be valid in objcache.
$options
array
Additional options for the cache replace operation.
Output
boolean
True if the replace was successful.
Details
visibility
public
final
false
static
false
access
public

set

set( string $key, mixed $var, integer $lifetime = 0, array $options = array ) : boolean

Set a key-value pair in a cache provider.

Arguments
$key
string
A unique key identifying the item being set.
$var
mixed
& $var A reference to the PHP variable representing the item.
$lifetime
integer
Seconds the item will be valid in objcache.
$options
array
Additional options for the cache set operation.
Output
boolean
True if the set was successful
Details
visibility
public
final
false
static
false
access
public

writeFile

writeFile( string $filename, string $content, string $mode = wb, array $options = array ) : boolean

Writes a file to the filesystem.

Arguments
$filename
string
The absolute path to the location the file will be written in.
$content
string
The content of the newly written file.
$mode
string
The php file mode to write in. Defaults to 'wb'. Note that this method always uses a (with b or t if specified) to open the file and that any mode except a means existing file contents will be overwritten.
$options
array
An array of options for the function.
Output
boolean
Returns true if the file was successfully written.
Details
visibility
public
final
false
static
false
access
public

writeTree

writeTree( string $dirname, array $options = array ) : boolean

Recursively writes a directory tree of files to the filesystem

Arguments
$dirname
string
The directory to write
$options
array
An array of options for the function. Can also be a value representing a permissions mode to write new directories with, though this is deprecated.
Output
boolean
Returns true if the directory was successfully written.
Details
visibility
public
final
false
static
false
access
public

\xPDOFileCache

Extends from
\xPDOCache
package
xpdo
subpackage
cache
Methods
__construct
add
delete
flush
get
getCacheKey
replace
set

Description

A simple file-based caching implementation using executable PHP.

This can be used to relieve database loads, though the overall performance is about the same as without the file-based cache. For maximum performance and scalability, use a server with memcached and the PHP memcache extension configured.

Methods

__construct

__construct(  $xpdo,  $options = array ) :
Arguments
$xpdo
$options
Details
visibility
public
final
false
static
false

add

add( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Adds a value to the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false

delete

delete( string $key, array $options = array ) : boolean

Deletes a value from the cache.

Arguments
$key
string
A unique key identifying the item being deleted.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false

flush

flush( array $options = array ) : boolean

Flush all values from the cache.

Arguments
$options
array
Additional options for the operation.
Output
boolean
True if successful.
Details
visibility
public
final
false
static
false

get

get( string $key, array $options = array ) : mixed

Gets a value from the cache.

Arguments
$key
string
A unique key identifying the item to fetch.
$options
array
Additional options for the operation.
Output
mixed
The value retrieved from the cache.
Details
visibility
public
final
false
static
false

getCacheKey

getCacheKey( string $key, array $options = array ) : string

Get the actual cache key the implementation will use.

Arguments
$key
string
The identifier the application uses.
$options
array
Additional options for the operation.
Output
string
The identifier with any implementation specific prefixes or other transformations applied.
Details
visibility
public
final
false
static
false

replace

replace( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Replaces a value in the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false

set

set( string $key, string $var, integer $expire = 0, array $options = array ) : boolean

Sets a value in the cache.

Arguments
$key
string
A unique key identifying the item being set.
$var
string
A reference to the PHP variable representing the item.
$expire
integer
The amount of seconds for the variable to expire in.
$options
array
Additional options for the operation.
Output
boolean
True if successful
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox 0.11.2.