NAME
Nile::Plugin::Cache - Cache plugin for the Nile framework.
SYNOPSIS
# save visitors count to the cache
$app->cache->set("visitor_count", $app->cache->get("visitor_count") + 1, "1 year");
# retrieve visitors count from the cache
$view->set("visitor_count", $app->cache->get("visitor_count"));
DESCRIPTION
Nile::Plugin::Cache - Cache plugin for the Nile framework.
Plugin settings in th config file under plugin
section. The autoload
variable is must be set to true value for the plugin to be loaded on application startup to setup hooks to work before actions dispatch:
<plugin>
<cache>
<autoload>0</autoload>
<driver>File</driver>
<root_dir></root_dir>
<namespace>cache</namespace>
</cache>
</plugin>
For DBI driver configuration example:
<driver>DBI</driver>
<namespace>cache</namespace>
<table_prefix>cache_</table_prefix>
<create_table>1</create_table>
The DBI create table example:
CREATE TABLE <table_prefix><namespace> (
`key` VARCHAR(...),
`value` TEXT,
PRIMARY KEY (`key`)
)
The driver will try to create the table if you set create_table
in the config and table does not exist.
cache()
$app->cache();
Returns the CHI cache object instance used. All CHI methods can be accessed through this method.
get set compute remove expire is_valid add replace append clear purge get_keys exists_and_is_expired
$app->cache->set($key, $data, "10 minutes");
$value = $app->cache->get($key);
These methods are a proxy to the CHI cache object methods. See CHI for details about these methods.
Bugs
This project is available on github at https://github.com/mewsoft/Nile.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Nile.
SOURCE
Source repository is at https://github.com/mewsoft/Nile.
SEE ALSO
See Nile for details about the complete framework.
AUTHOR
Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> Website: http://www.mewsoft.com
COPYRIGHT AND LICENSE
Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, https://github.com/mewsoft/Nile, http://www.mewsoft.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.