This is documentation for Kohana v2.3.x.
Status | current page status |
---|---|
Todo | what needs to be done next |
Introduce the topic, provide general overview of usage and any relevant info.
For the API documentation:
if applicable List any relevant links to information Kohana Forum
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;
config['driver']
sets the driver, which is the container for your cached files. There are 6 different drivers:
$config['params']
contains driver specific parameters. (in above example - path to server writable cache dir)
$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
$config['requests']
average number of requests before automatic garbage collection begins. Set to a negative number will disable automatic garbage collection
$this->cache= new Cache;
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:
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.
set($id, $data, $tags = NULL, $lifetime = NULL)
is used to set caches. get($id)
retrieves a cache with the given $id, returns the data or NULLfind($tag)
supply with a string, retrieves all caches with the given tag.delete($id)
deletes a cache item by id, returns a boolean.delete_tag($tag)
deletes all cache items with a given tag, returns a boolean.delete_all()
deletes all cache items, returns a boolean.
set($id,$data,$tags = NULL, $lifetime = NULL)
is used to set caches.
$id
The ID of the cached data. Must be unique.$data
If $data is not a string it will be serialized for storage. $tags
defaults to none, an array should be supplied. This is useful when grouping caches together.$lifetime
specific lifetime can be set. If none given the default lifetime from the configuration file will be used.$data=array('Jean Paul Sartre', 'Albert Camus', 'Simone de Beauvoir'); $tags=array('existentialism','philosophy','french'); $this->cache->set('existentialists',$data,$tags);
get($id)
retrieves a cache with the given $id, returns the data or NULL
find($tag)
supply with a string, retrieves all caches with the given tag.
Add all other methods methods here.
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);
If applicable, list a full code example here. Or provide links to online examples as well.