1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-28 00:00:05 +02:00

add Minify::getCache() and Minify_Cache_Abstract that all cache classes must implement

This commit is contained in:
Elan Ruusamäe
2014-09-20 15:15:25 +03:00
committed by Steve Clay
parent f29e1e6b06
commit bd8f3faacc
8 changed files with 80 additions and 8 deletions

View File

@@ -85,6 +85,16 @@ class Minify {
self::$_cache = $cache;
}
}
/**
* Get Minify cache
*
* @return Minify_Cache_Abstract|null
*/
public static function getCache()
{
return self::$_cache;
}
/**
* Serve a request for a minified file.
@@ -396,7 +406,7 @@ class Minify {
/**
* Any Minify_Cache_* object or null (i.e. no server cache is used)
*
* @var Minify_Cache_File
* @var Minify_Cache_Abstract
*/
private static $_cache = null;

View File

@@ -14,7 +14,7 @@
* @package Minify
* @author Chris Edwards
**/
class Minify_Cache_APC {
class Minify_Cache_APC extends Minify_Cache_Abstract {
/**
* Create a Minify_Cache_APC object, to be passed to

View File

@@ -0,0 +1,63 @@
<?php
/**
* Class Minify_Cache_Abstract
*
* @package Minify
*/
abstract class Minify_Cache_Abstract {
/**
* Write data to cache.
*
* @param string $id cache id (e.g. a filename)
* @param string $data
*
* @return bool success
*/
public function store($id, $data)
{
}
/**
* Get the size of a cache entry
*
* @param string $id cache id (e.g. a filename)
*
* @return int size in bytes
*/
public function getSize($id)
{
}
/**
* Does a valid cache entry exist?
*
* @param string $id cache id (e.g. a filename)
* @param int $srcMtime mtime of the original source file(s)
*
* @return bool exists
*/
public function isValid($id, $srcMtime)
{
}
/**
* Send the cached content to output
*
* @param string $id cache id (e.g. a filename)
*/
public function display($id)
{
}
/**
* Fetch the cached content
*
* @param string $id cache id (e.g. a filename)
*
* @return string
*/
public function fetch($id)
{
}
}

View File

@@ -4,7 +4,7 @@
* @package Minify
*/
class Minify_Cache_File {
class Minify_Cache_File extends Minify_Cache_Abstract {
public function __construct($path = '', $fileLocking = false)
{

View File

@@ -17,7 +17,7 @@
* }
* </code>
**/
class Minify_Cache_Memcache {
class Minify_Cache_Memcache extends Minify_Cache_Abstract {
/**
* Create a Minify_Cache_Memcache object, to be passed to

View File

@@ -14,8 +14,7 @@
* @package Minify
* @author Matthias Fax
**/
class Minify_Cache_WinCache
{
class Minify_Cache_WinCache extends Minify_Cache_Abstract {
/**
* Create a Minify_Cache_Wincache object, to be passed to

View File

@@ -17,7 +17,7 @@
* @package Minify
* @author Elan Ruusamäe <glen@delfi.ee>
**/
class Minify_Cache_XCache {
class Minify_Cache_XCache extends Minify_Cache_Abstract {
/**
* Create a Minify_Cache_XCache object, to be passed to

View File

@@ -17,7 +17,7 @@
* @package Minify
* @author Patrick van Dissel
*/
class Minify_Cache_ZendPlatform {
class Minify_Cache_ZendPlatform extends Minify_Cache_Abstract {
/**