^Status|current page status|
^Todo|what needs to be done next|
====== Sample Main Heading ======
Introduce the topic, provide general overview of usage and any relevant info.
For the API documentation:
* if available
**if applicable** List any relevant links to information [[http://forum.kohanaphp.com|Kohana Forum]]
===== Configuration =====
Describe how to configure, if applicable. Describe the config items, what they do, how to use them.
Example from Cache Library:
$config['driver'] = 'file';
$config['params'] = APPPATH . 'cache';
$config['lifetime'] = 1800;
$config['requests'] = 1000;
=== Drivers ===
''config['driver']'' sets the driver, which is the container for your cached files. There are 6 different drivers:
* File - File cache is fast and reliable, but requires many filesystem lookups.
* SQlite - Database cache can be used to cache items remotely, but is slower.
* Memcache - Memcache is very high performance, but prevents cache tags from being used.
* APC - Alternative Php Cache
* Eaccelerator
* Xcache
=== Driver parameters ===
''$config['params']'' contains driver specific parameters. (in above example - path to server writable cache dir)
=== Cache Lifetime ===
''$config['lifetime']'' sets the lifetime of the cache. Specific lifetime can be set when creating a new cache. 0 means it will never be deleted automatically
=== Garbage Collector ===
''$config['requests']'' average number of requests before automatic garbage collection begins. Set to a negative number will disable automatic garbage collection
===== How to get/instantiate the object =====
$this->cache= new Cache;
===== How is the thing used =====
Explain usage here. (sample from Cache library)
Give a code example:
$this->cache= new Cache;
$table = $this->cache->get('table');
if ( ! $table) {
$table = build_table();
$this->cache->set('table', $table, array('mytag1', 'mytag2'), 3600);
}
echo $table;
Explain in detail:
There are 3 main steps:
* Instantiate the cache library
* Get the cache:
* If the cache doesn't exist, we build the table by querying the database, we cache it for 1 hour (3600 seconds) for next requests and we print it.
* If the cache exists, we directly print the cached version of the table
===== Methods =====
List all the public methods (example from Cache library)
**Use a descriptive name for the main heading**, followed by the method name as sub heading.
* ''[[sample#set|set]]($id, $data, $tags = NULL, $lifetime = NULL)'' is used to set caches.
* ''[[sample#get|get]]($id)'' retrieves a cache with the given $id, returns the data or NULL
* ''[[sample#find|find]]($tag)'' supply with a string, retrieves all caches with the given tag.
* ''[[sample#delete|delete]]($id)'' deletes a cache item by id, returns a boolean.
* ''[[sample#delete_tag|delete_tag]]($tag)'' deletes all cache items with a given tag, returns a boolean.
* ''[[sample#delete_all|delete_all]]()'' deletes all cache items, returns a boolean.
==== Setting caches ====
=== set ===
''set($id,$data,$tags = NULL, $lifetime = NULL)'' is used to set caches.
* **[string]** ''$id'' The ID of the cached data. Must be unique.
* **[mixed]** ''$data'' If $data is not a string it will be serialized for storage.
* **[mixed]** ''$tags''defaults to none, an array should be supplied. This is useful when grouping caches together.
* **[mixed]** ''$lifetime'' specific lifetime can be set. If none given the default lifetime from the configuration file will be used.
* returns **[mixed]** The cached data.
$data=array('Jean Paul Sartre', 'Albert Camus', 'Simone de Beauvoir');
$tags=array('existentialism','philosophy','french');
$this->cache->set('existentialists',$data,$tags);
==== Finding and getting caches====
=== get ===
''get($id)'' retrieves a cache with the given $id, returns the data or NULL
=== find ===
''find($tag)'' supply with a string, retrieves all caches with the given tag.
Add all other methods methods here.
===== Database Table Schema =====
**if applicable**
If a database is required, list the schema here.
create table caches(
id varchar(127),
hash char(40),
tags varchar(255),
expiration int,
cache blob);
===== Full coded example =====
If applicable, list a full code example here. Or provide links to online examples as well.