Updated to KH 3.3 and improved

This commit is contained in:
Deon George
2013-04-13 16:17:56 +10:00
parent 6f50463ec7
commit 6f7913d363
1551 changed files with 96188 additions and 29813 deletions

View File

@@ -67,7 +67,7 @@ Certain cache drivers support setting values with tags. To set a value to cache
$memcache = Cache::instance('memcachetag');
// Test for tagging interface
if ($memcache instanceof Kohana_Cache_Tagging)
if ($memcache instanceof Cache_Tagging)
{
// Set a value with some tags for 30 seconds
$memcache->set('foo', $object, 30, array('snafu', 'stfu', 'fubar'));
@@ -79,7 +79,7 @@ Certain cache drivers support setting values with tags. To set a value to cache
$memcache->set('foo', $object, 30);
}
It is possible to implement custom tagging solutions onto existing or new cache drivers by implementing the [Kohana_Cache_Tagging] interface. Kohana_Cache only applies the interface to drivers that support tagging natively as standard.
It is possible to implement custom tagging solutions onto existing or new cache drivers by implementing the [Cache_Tagging] interface. Kohana_Cache only applies the interface to drivers that support tagging natively as standard.
### Getting a value from cache
@@ -115,7 +115,7 @@ It is possible to retrieve values from cache grouped by tag, using the [Cache::f
// Find values based on tag
return $cache->find('snafu');
}
catch (Kohana_Cache_Exception $e)
catch (Cache_Exception $e)
{
// Handle gracefully
return FALSE;
@@ -170,7 +170,7 @@ Some of the caching drivers support deleting by tag. This will remove all the ca
$cache = Cache::instance();
// Check for tagging interface
if ($cache instanceof Kohana_Cache_Tagging)
if ($cache instanceof Cache_Tagging)
{
// Delete all entries by the tag 'snafu'
$cache->delete_tag('snafu');
@@ -189,7 +189,7 @@ When not automated, garbage collection is the responsibility of the developer. I
$gc = 10;
// If the GC probability is a hit
if (rand(0,99) <= $gc and $cache_file instanceof Kohana_Cache_GarbageCollect)
if (rand(0,99) <= $gc and $cache_file instanceof Cache_GarbageCollect)
{
// Garbage Collect
$cache_file->garbage_collect();
@@ -199,10 +199,10 @@ When not automated, garbage collection is the responsibility of the developer. I
Kohana Cache comes with two interfaces that are implemented where the drivers support them:
- __[Kohana_Cache_Tagging] for tagging support on cache entries__
- __[Cache_Tagging] for tagging support on cache entries__
- [Cache_MemcacheTag]
- [Cache_Sqlite]
- __[Kohana_Cache_GarbageCollect] for garbage collection with drivers without native support__
- __[Cache_GarbageCollect] for garbage collection with drivers without native support__
- [Cache_File]
- [Cache_Sqlite]
@@ -212,7 +212,7 @@ When using interface specific caching features, ensure that code checks for the
$cache = Cache::instance();
// Test for Garbage Collection
if ($cache instanceof Kohana_Cache_GarbageCollect)
if ($cache instanceof Cache_GarbageCollect)
{
// Collect garbage
$cache->garbage_collect();

View File

@@ -58,7 +58,7 @@ failure_callback | __NO__ | (_[callback](http://www.php.net/manual/en/language
(can cause issues with integers)
'servers' => array
(
array
'local' => array
(
'host' => 'localhost', // Memcache Server
'port' => 11211, // Memcache port number
@@ -74,7 +74,7 @@ failure_callback | __NO__ | (_[callback](http://www.php.net/manual/en/language
(can cause issues with integers)
'servers' => array
(
array
'local' => array
(
'host' => 'localhost', // Memcache Server
'port' => 11211, // Memcache port number
@@ -102,21 +102,6 @@ failure_callback | __NO__ | (_[callback](http://www.php.net/manual/en/language
tags VARCHAR(255), expiration INTEGER, cache TEXT)',
),
## Eaccelerator settings
'eaccelerator' array
(
'driver' => 'eaccelerator',
),
## Xcache settings
'xcache' => array
(
'driver' => 'xcache',
'default_expire' => 3600,
),
## File settings
'file' => array
@@ -126,6 +111,15 @@ failure_callback | __NO__ | (_[callback](http://www.php.net/manual/en/language
'default_expire' => 3600,
)
## Wincache settings
'wincache' => array
(
'driver' => 'wincache',
'default_expire' => 3600,
),
## Override existing configuration group
The following example demonstrates how to override an existing configuration setting, using the config file in `/application/config/cache.php`.
@@ -165,4 +159,4 @@ The following example demonstrates how to add a new configuration setting, using
'driver' => 'apc', // Use Memcached as the default driver
'default_expire' => 1000, // Overide default expiry
)
);
);

View File

@@ -1,18 +1,17 @@
# About Kohana Cache
[Kohana_Cache] provides a common interface to a variety of caching engines. [Kohana_Cache_Tagging] is
[Kohana_Cache] provides a common interface to a variety of caching engines. [Cache_Tagging] is
supported where available natively to the cache system. Kohana Cache supports multiple
instances of cache engines through a grouped singleton pattern.
## Supported cache engines
* APC ([Cache_Apc])
* eAccelerator ([Cache_Eaccelerator])
* File ([Cache_File])
* Memcached ([Cache_Memcache])
* Memcached-tags ([Cache_Memcachetag])
* SQLite ([Cache_Sqlite])
* Xcache ([Cache_Xcache])
* Wincache
## Introduction to caching
@@ -45,13 +44,12 @@ Getting and setting values to cache is very simple when using the _Kohana Cache_
Driver | Storage | Speed | Tags | Distributed | Automatic Garbage Collection | Notes
---------------- | ------------ | --------- | -------- | ----------- | ---------------------------- | -----------------------
APC | __Memory__ | Excellent | No | No | Yes | Widely available PHP opcode caching solution, improves php execution performance
eAccelerator | __Memory__ | Excellent | No | No | Yes | Limited support and no longer developed. Included for legacy systems
Wincache | __Memory__ | Excellent | No | No | Yes | Windows variant of APC
File | __Disk__ | Poor | No | No | No | Marginally faster than execution
Memcache (tag) | __Memory__ | Good | No (yes) | Yes | Yes | Generally fast distributed solution, but has a speed hit due to variable network latency
Memcache (tag) | __Memory__ | Good | No (yes) | Yes | Yes | Generally fast distributed solution, but has a speed hit due to variable network latency and serialization
Sqlite | __Disk__ | Poor | Yes | No | No | Marginally faster than execution
Xcache | __Memory__ | Excellent | Yes | No | Yes | Very fast memory solution and alternative to APC
It is possible to have hybrid cache solutions that use a combination of the engines above in different contexts. This is supported with _Kohana Cache_ as well.
It is possible to have hybrid cache solutions that use a combination of the engines above in different contexts. This is supported with _Kohana Cache_ as well
## Minimum requirements

View File

@@ -67,7 +67,7 @@ Certain cache drivers support setting values with tags. To set a value to cache
$memcache = Cache::instance('memcachetag');
// Test for tagging interface
if ($memcache instanceof Kohana_Cache_Tagging)
if ($memcache instanceof Cache_Tagging)
{
// Set a value with some tags for 30 seconds
$memcache->set('foo', $object, 30, array('snafu', 'stfu', 'fubar'));
@@ -79,7 +79,7 @@ Certain cache drivers support setting values with tags. To set a value to cache
$memcache->set('foo', $object, 30);
}
It is possible to implement custom tagging solutions onto existing or new cache drivers by implementing the [Kohana_Cache_Tagging] interface. Kohana_Cache only applies the interface to drivers that support tagging natively as standard.
It is possible to implement custom tagging solutions onto existing or new cache drivers by implementing the [Cache_Tagging] interface. Kohana_Cache only applies the interface to drivers that support tagging natively as standard.
### Getting a value from cache
@@ -115,7 +115,7 @@ It is possible to retrieve values from cache grouped by tag, using the [Cache::f
// Find values based on tag
return $cache->find('snafu');
}
catch (Kohana_Cache_Exception $e)
catch (Cache_Exception $e)
{
// Handle gracefully
return FALSE;
@@ -170,7 +170,7 @@ Some of the caching drivers support deleting by tag. This will remove all the ca
$cache = Cache::instance();
// Check for tagging interface
if ($cache instanceof Kohana_Cache_Tagging)
if ($cache instanceof Cache_Tagging)
{
// Delete all entries by the tag 'snafu'
$cache->delete_tag('snafu');
@@ -189,7 +189,7 @@ When not automated, garbage collection is the responsibility of the developer. I
$gc = 10;
// If the GC probability is a hit
if (rand(0,99) <= $gc and $cache_file instanceof Kohana_Cache_GarbageCollect)
if (rand(0,99) <= $gc and $cache_file instanceof Cache_GarbageCollect)
{
// Garbage Collect
$cache_file->garbage_collect();
@@ -199,10 +199,10 @@ When not automated, garbage collection is the responsibility of the developer. I
Kohana Cache comes with two interfaces that are implemented where the drivers support them:
- __[Kohana_Cache_Tagging] for tagging support on cache entries__
- __[Cache_Tagging] for tagging support on cache entries__
- [Cache_MemcacheTag]
- [Cache_Sqlite]
- __[Kohana_Cache_GarbageCollect] for garbage collection with drivers without native support__
- __[Cache_GarbageCollect] for garbage collection with drivers without native support__
- [Cache_File]
- [Cache_Sqlite]
@@ -212,7 +212,7 @@ When using interface specific caching features, ensure that code checks for the
$cache = Cache::instance();
// Test for Garbage Collection
if ($cache instanceof Kohana_Cache_GarbageCollect)
if ($cache instanceof Cache_GarbageCollect)
{
// Collect garbage
$cache->garbage_collect();