PHP Class JamesMoss\Flywheel\CachedQuery

A extension of Query that is able to store results in shared memory (via the apc_* functions) so that they can be retieved for future use with minimal performance impact.
Inheritance: extends Query
Show file Open project: jamesmoss/flywheel Class Usage Examples

Public Methods

Method Description
execute ( ) : Result Checks the cache to see if this query exists and returns it. If it's not in the cache then the query is run, stored and then returned.

Protected Methods

Method Description
getFileHash ( ) : string Gets a hash based on the files in the repo directory. If the contents of a file changes, or other files are added/deleted the hash will change.
getParameterHash ( ) : string Generates a hash based on the parameters set in the query.

Method Details

execute() public method

Checks the cache to see if this query exists and returns it. If it's not in the cache then the query is run, stored and then returned.
public execute ( ) : Result
return Result The result of the query.

getFileHash() protected method

Uses filematime() for speed when checking for file changes (rather than using crc32 or md5 etc)
protected getFileHash ( ) : string
return string A 128bit hash in hexadecimal format.

getParameterHash() protected method

Generates a hash based on the parameters set in the query.
protected getParameterHash ( ) : string
return string A 128bit hash in hexadecimal format.