PHP Class Stash_model

Author: Mark Croxton ([email protected])
Inheritance: extends CI_Model
Datei anzeigen Open project: croxton/stash Class Usage Examples

Public Properties

Property Type Description
$EE

Protected Properties

Property Type Description
$bundle_ids default bundle types
$inserted_keys
$keys
$queue

Public Methods

Method Description
__construct ( )
bundle_entry_count ( $bundle_id, $site_id = 1 ) : boolean Count the number of entries for a given bundle
bundle_entry_exists ( $bundle_id, $site_id = 1 ) : integer Check if there is at least one entry for the bundle in this site
delete_key ( string $key, integer/boolean $bundle_id = FALSE, string $session_id = NULL, integer $site_id = 1, integer $invalidate ) : boolean Delete key(s) by name, optionally limited to keys registered with the user session
delete_matching_keys ( integer/boolean $bundle_id = FALSE, string $session_id = NULL, integer $site_id = 1, string $regex = NULL, integer $invalidate ) : boolean Delete key(s) matching a regular expression, and/or scope, and/or bundle
flush_cache ( integer $site_id = 1 ) : boolean Flush the entire cache for a given site, immediately
get_bundle_by_id ( integer $bundle_id ) : integer Get a bundle name from the id
get_bundle_by_name ( string $bundle ) : integer Get a bundle id from the name
get_index_key ( ) : string Getter: returns the index key placeholder
get_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, string $col = 'parameters' ) : string Get key value
get_key_expiry ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1 ) : timestamp Get key expiry date
get_queue ( ) : object Get the Queue object by reference
insert_bundle ( string $bundle, integer $bundle_label = '' ) Insert a bundle
insert_key ( string $key, integer $bundle_id = 1, string $session_id, integer $site_id = 1, integer $expire, string $parameters = '', string $label = '' ) : boolean Insert key for user session
is_inserted_key ( string $cache_key ) : boolean Check to see if a key has been inserted within this page load
parse_uri_from_key ( string $key ) : string Parse a URI from a stash variable key (typically, the uri of a cached page)
process_queue ( ) : boolean Process queued queries
prune_keys ( ) : boolean Prune expired keys
refresh_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, integer $refresh ) : boolean Refresh key for user session
update_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, integer $expire, string $parameters = NULL ) : boolean Update key for user session

Protected Methods

Method Description
delete_cache ( array $vars, boolean $clear_static = TRUE, integer $invalidate, $call_hook = TRUE ) : boolean Delete an array of variables in a given site
delete_static_cache ( integer $key, string $bundle_id, $site_id ) : boolean Delete the associated static file for a given variable
insert_ignore_batch ( string $table, array $data ) : Null Prepare INSERT IGNORE BATCH SQL query
queue_insert ( string $table, string $cache_key, Array $data ) : boolean Queue an insert for batch processing later
queue_update ( string $table, string $cache_key, Array $data, Array $where ) : boolean Queue an update for batch processing later
write_static_cache ( string $key, integer $bundle_id, $site_id, string $parameters ) : boolean Check if the variable can be cached as a static file and write it

Private Methods

Method Description
_can_static_cache ( integer $bundle_id ) : boolean Check that static cache is enabled, and the bundle is static
_delete_dir ( string $uri, $site_id ) : boolean Recursively delete directories and files in a static cache directory
_delete_file ( string $uri = '/', $site_id ) : boolean Delete a static file
_invalidate ( array $ids, integer $period ) : boolean Update variables to expire at random intervals within the invalidation period and so help prevent cache stampedes
_path ( string $uri = '/', $site_id ) : string/boolean Returns the path to the cache directory, if it exists
_write_file ( string $uri, $site_id, string $parameters = NULL ) : boolean Write a static file

Method Details

__construct() public method

public __construct ( )

bundle_entry_count() public method

Count the number of entries for a given bundle
public bundle_entry_count ( $bundle_id, $site_id = 1 ) : boolean
return boolean

bundle_entry_exists() public method

Check if there is at least one entry for the bundle in this site
public bundle_entry_exists ( $bundle_id, $site_id = 1 ) : integer
return integer

delete_cache() protected method

Delete an array of variables in a given site
protected delete_cache ( array $vars, boolean $clear_static = TRUE, integer $invalidate, $call_hook = TRUE ) : boolean
$vars array An array of objects
$clear_static boolean Clear the static cache too, for variables in the static bundle?
$invalidate integer Delay until cached item expires (seconds)
return boolean

delete_key() public method

Delete key(s) by name, optionally limited to keys registered with the user session
public delete_key ( string $key, integer/boolean $bundle_id = FALSE, string $session_id = NULL, integer $site_id = 1, integer $invalidate ) : boolean
$key string
$bundle_id integer/boolean
$session_id string
$site_id integer
$invalidate integer Delay until cached item expires (seconds)
return boolean

delete_matching_keys() public method

Delete key(s) matching a regular expression, and/or scope, and/or bundle
public delete_matching_keys ( integer/boolean $bundle_id = FALSE, string $session_id = NULL, integer $site_id = 1, string $regex = NULL, integer $invalidate ) : boolean
$bundle_id integer/boolean
$session_id string
$site_id integer
$regex string a regular expression
$invalidate integer Delay until cached item expires (seconds)
return boolean

delete_static_cache() protected method

Delete the associated static file for a given variable
protected delete_static_cache ( integer $key, string $bundle_id, $site_id ) : boolean
$key integer
$bundle_id string
return boolean

flush_cache() public method

Flush the entire cache for a given site, immediately
public flush_cache ( integer $site_id = 1 ) : boolean
$site_id integer
return boolean

get_bundle_by_id() public method

Get a bundle name from the id
public get_bundle_by_id ( integer $bundle_id ) : integer
$bundle_id integer
return integer

get_bundle_by_name() public method

Get a bundle id from the name
public get_bundle_by_name ( string $bundle ) : integer
$bundle string
return integer

get_index_key() public method

Getter: returns the index key placeholder
public get_index_key ( ) : string
return string

get_key() public method

Get key value
public get_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, string $col = 'parameters' ) : string
$key string
$session_id string
$site_id integer
$col string
return string

get_key_expiry() public method

Get key expiry date
public get_key_expiry ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1 ) : timestamp
$key string
$session_id string
$site_id integer
return timestamp / boolean

get_queue() public method

Get the Queue object by reference
public get_queue ( ) : object
return object

insert_bundle() public method

Insert a bundle
public insert_bundle ( string $bundle, integer $bundle_label = '' )
$bundle string
$bundle_label integer

insert_ignore_batch() protected method

Prepare INSERT IGNORE BATCH SQL query
protected insert_ignore_batch ( string $table, array $data ) : Null
$table string The table to insert into
$data array Array in form of "Column" => "Value", ...
return Null

insert_key() public method

Insert key for user session
public insert_key ( string $key, integer $bundle_id = 1, string $session_id, integer $site_id = 1, integer $expire, string $parameters = '', string $label = '' ) : boolean
$key string
$bundle_id integer
$session_id string
$site_id integer
$expire integer
$parameters string
$label string
return boolean

is_inserted_key() public method

Check to see if a key has been inserted within this page load
public is_inserted_key ( string $cache_key ) : boolean
$cache_key string
return boolean

parse_uri_from_key() public method

Parse a URI from a stash variable key (typically, the uri of a cached page)
public parse_uri_from_key ( string $key ) : string
$key string
return string

process_queue() public method

Process queued queries
public process_queue ( ) : boolean
return boolean

prune_keys() public method

Prune expired keys
public prune_keys ( ) : boolean
return boolean

queue_insert() protected method

Queue an insert for batch processing later
protected queue_insert ( string $table, string $cache_key, Array $data ) : boolean
$table string The table to insert into
$cache_key string Unique key identifying this variable
$data Array Array in form of "Column" => "Value", ...
return boolean

queue_update() protected method

Queue an update for batch processing later
protected queue_update ( string $table, string $cache_key, Array $data, Array $where ) : boolean
$table string The table to insert into
$cache_key string Unique key identifying this variable
$data Array Array in form of "Column" => "Value", ...
$where Array Array in form of "Column" => "Value", ...
return boolean

refresh_key() public method

Refresh key for user session
public refresh_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, integer $refresh ) : boolean
$key string
$session_id string
$site_id integer
$refresh integer Seconds to expiry date
return boolean

update_key() public method

Update key for user session
public update_key ( string $key, $bundle_id = 1, string $session_id = '', integer $site_id = 1, integer $expire, string $parameters = NULL ) : boolean
$key string
$session_id string
$site_id integer
$expire integer
$parameters string
return boolean

write_static_cache() protected method

Check if the variable can be cached as a static file and write it
protected write_static_cache ( string $key, integer $bundle_id, $site_id, string $parameters ) : boolean
$key string
$bundle_id integer
$parameters string
return boolean

Property Details

$EE public_oe property

public $EE

$bundle_ids protected_oe static_oe property

default bundle types
protected static $bundle_ids

$inserted_keys protected_oe static_oe property

protected static $inserted_keys

$keys protected_oe static_oe property

protected static $keys

$queue protected_oe static_oe property

protected static $queue