NAME
Class::DBI::Lite::CacheManager::InMemory - Cache in RAM.
SYNOPSIS
package My::City;
use strict;
use warnings 'all';
use base 'My::Model';
use Class::DBI::Lite::CacheManager::InMemory;
__PACKAGE__->set_up_table('cities');
__PACKAGE__->set_cache(
Class::DBI::Lite::CacheManager::Memcached->new(
lifetime => '30s',
class => __PACKAGE__,
do_cache_search => 1,
)
);
__PACKAGE__->cache->cache_searches_containing(qw(
email
password
));
Then, someplace else...
# This will be cached...
my ($user) = My::User->search(
email => 'alice@wonderland.net',
password => 'whiterabbit',
);
...later...
# This won't hit the database - the result will come from the cache instead:
my ($user) = My::User->search(
email => 'alice@wonderland.net',
password => 'whiterabbit',
);
A create, update or delete invalidates the cache:
$user->delete; # Cache is emptied now.
DESCRIPTION
Class::DBI::Lite::CacheManager::InMemory
will store the results of searches in RAM for a specific length of time. This is helpful if you find that your application's performance is suffering because of oft-repeated queries.
So, if your data requirements are such that you find objects of a specific class are getting called up frequently enough to warrant caching - you can now do that on a per-class basis.
You can even specify the kinds of search queries that should be cached.
You can specify the length of time that cached data should be available.
NOTE: More documentation and complete examples TBD.
AUTHOR
Copyright John Drago <jdrago_999@yahoo.com>. All rights reserved.
LICENSE
This software is Free software and may be used and redistributed under the same terms as perl itself.