Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eusonlito/cache
PHP Cache Interface
https://github.com/eusonlito/cache
Last synced: about 1 month ago
JSON representation
PHP Cache Interface
- Host: GitHub
- URL: https://github.com/eusonlito/cache
- Owner: eusonlito
- Created: 2012-06-20T08:42:34.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-15T12:03:24.000Z (about 11 years ago)
- Last Synced: 2024-04-27T13:25:36.233Z (7 months ago)
- Language: PHP
- Size: 73.2 KB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Cache
=====This script works as simple interface with APC, Memcache, Memcached and Files to store data into cache.
You will can store different data into different cache methods (some examples into settings-example.php).
Examples
--------#### Files cache
exists('js-files')) {
$content = $Cache->get('js-files');
} else {
$content = file_get_contents('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
$content .= file_get_contents('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
$content .= file_get_contents('http://modernizr.com/i/js/modernizr.com-custom-1.6.js');// Cache expired time is loaded from settings
// but you can set your own time in seconds from now
// Third parameter is optional
$Cache->set('js-files', $content, $custom_time);
}#### Database Query cache (into APC)
exists($cache_key)) {
$rows = $Cache->get($cache_key);
} else {
$rows = mysql_fetch_assoc(mysql_query($query));// Cache expired time is loaded from settings
// but you can set your own time in seconds from now
// Third parameter is optional
$Cache->set($cache_key, $rows, $custom_time);
}#### Configuration cache (into Memcache)
exists($cache_key)) {
$configuration = $Cache->get($cache_key);
} else {
$configuration = array();foreach ($config_files as $file) {
if (is_file(__DIR__.'/config/'.$file.'.php')) {
$configuration = array_replace_recursive($configuration, include(__DIR__.'/config/'.$file.'.php'));
}
}// Cache expired time is loaded from settings
// but you can set your own time in seconds from now
// Third parameter is optional
$Cache->set($cache_key, $configuration, $custom_time);
}