NAME
Beekeeper::Worker::Util::SharedCache - Locally mirrored shared cache
VERSION
Version 0.03
SYNOPSIS
use Beekeeper::Worker::Util 'shared_cache'
my $c = $self->shared_cache(
id => "mycache",
max_age => 300,
persist => 1,
);
$c->set( $key => $value );
$c->get( $key );
$c->delete( $key );
$c->touch( $key );
DESCRIPTION
This module implements a locally mirrored shared cache: each worker keeps a copy of all cached data, and all copies are synced through message bus.
Access operations are essentially free, as data is held locally. But changes are expensive as they need to be propagated to every worker, and overall memory usage is high due to data cloning.
Keep in mind that retrieved data may be stale due to latency in the propagation of changes through the bus which involves two MQTT messages.
Even if you are using this cache for small data sets that do not change very often, please consider if a distributed memory cache (or even a plain DB) is a better alternative.
Due to propagation costs, this cache does not scale.
AUTHOR
José Micó, jose.mico@gmail.com
COPYRIGHT AND LICENSE
Copyright 2015-2021 José Micó.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language itself.
This software is distributed in the hope that it will be useful, but it is provided “as is” and without any express or implied warranties. For details, see the full text of the license in the file LICENSE.