The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Memoize::Memcached - use a memcached cache to memoize functions

VERSION

Version 0.01

SYNOPSIS

use Memoize::Memcached
  memcached => {
    servers => [ '127.0.0.1:11211' ],
  };

memoize_memcached('foo');

# Function 'foo' is now memoized using the memcached server
# running on 127.0.0.1:11211 as the cache.

EXPORT

This module exports memoize_memcached, flush_cache, and unmemoize. The unmemoize function is just the one from Memoize, and is exported only for convenience.

FUNCTIONS

flush_cache

The behavior documented in Memoize is sort of implemented. A call to flush_cache('memoized_function') will indeed clear the cache of all cached return values for that function, BUT it will also clear the entire memcached cache, including data unrelated to Memoize::Memcached.

There are 2 new ways to call this function:

flush_cache();

and

flush_cache(memoized_function => qw( an argument signature ));

The call without arguments will flush the entire memcached cache. This includes unrelated data. Be careful.

The call with 2 or more arguments will flush only the cached return values (array and scalar contexts) for a call to the funcation named by the first argument with an argument signature matching the second argument to the end. Unlike the other 2 ways to call this function, when called this way only the specified part of the cache is flushed.

Currently, it is recommended that only the 2 or more argument version of flush_cache be called.

GOTCHAS

The biggest gotcha is that you probably never want to call flush_cache('memoized_function'). Because of the way CLEAR is implemented against memcached, this call will flush the entire memcached cache. Everything. Even stuff having nothing to do with Memoize::Memcached. You are warned.

TO-DO

A more intuitive interface for handling different memcached server configurations would probably be useful.

A lot more documentation.

AUTHOR

David Trischuk, <trischuk at gmail.com>

BUGS

Please report any bugs or feature requests to bug-tmp-tmp at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tmp-Tmp. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Memoize::Memcached

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2008 David Trischuk, all rights reserved.

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