NAME
Cache::Memcached::Mock - A mock class for Cache::Memcached
VERSION
version 0.03
SYNOPSIS
Supports only a subset of Cache::Memcached functionality.
# Any arguments are just ignored
my $cache = Cache::Memcached::Mock->new();
# Values are stored in a process global hash
my $value = $cache->get('somekey');
my $set_ok = $cache->set('someotherkey', 'somevalue');
$set_ok = $cache->set('someotherkey', 'somevalue', 60); # seconds
# new() also flushes all values
$cache->flush_all();
my $pairs = $cache->get_multi('key1', 'key2', '...');
DESCRIPTION
This class can be used to mock the real Cache::Memcached object when you don't have a memcached server running (and you don't want to run one actually), but you need the functionality to be there.
I used it in unit tests, where I had to perform several tests against a given memcached instance, to see that certain values were really created or deleted.
Instead of having a memcached instance running for every server where I need unit tests running, or using a centralized memcached daemon, I can just pass a Cache::Memcached::Mock instance wherever a Cache::Memcached one is required.
This is an example of how you would use this mock class:
# Use the "Mock" one instead of C::MC
my $memc = Cache::Memcached::Mock->new();
my $business_object = My::Business->new({
memcached_instance => $memc
});
$business_object->do_something_that_involves_caching();
In short, this allows you to avoid setting up a real memcached instance whenever you don't necessarily need one, for example unit testing.
NAME
Cache::Memcached::Mock - A mock class for Cache::Memcached
VERSION
version 0.03
AUTHOR
Cosimo Streppone <cosimo@opera.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Opera Software ASA.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
AUTHOR
Cosimo Streppone <cosimo@opera.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Opera Software ASA.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.