NAME

CHI::Driver::MySQL - Use MySQL for cache storage

VERSION

version 1.0

SYNOPSIS

use CHI;

# Supply Data Source Name, defaults to C<dbi:mysql:dbname=test>.
#
my $cache = CHI->new( driver => 'MySQL', dsn => 'mysql://user:password@host:port/database' );

DESCRIPTION

This driver uses a `chi_cache` table to store the cache. The table is created by the driver itself.

Encode is required for encoding as UTF-8 the value that is about to be stored in database Mojo::mysql is required for connection to database

ATTRIBUTES CHI::Driver::MySQL implements the following attributes.

dsn Data Source Name, defaults to dbi:mysql:dbname=test.

namespace The namespace to be used, defaults to default.

mysql Mojo::mysql instance.

METHODS CHI::Driver::MySQL inherits all methods from CHI::Driver and implements the following new ones.

clear $cache->clear Remove all the entries from chi_cache table for current namespace.

fetch $cache->fetch($key) Fetch a row from chi_cache table for current namespace and given $key.

get_keys $cache->get_keys Get all the keys from chi_cache table for current namespace.

get_namespaces $cache->get_namespaces Get all the namespaces from chi_cache table.

remove $cache->remove($key) Remove a key from chi_cache table for current namespace.

store $cache->store($key, $data) Store key and data in chi_cache table for current namespace.

AUTHOR

Adrian Crisan, <adrian.crisan88@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Adrian Crisan.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.