NAME
Beekeeper::Worker::Extension::SharedCache - Locally mirrored shared cache
VERSION
Version 0.09
SYNOPSIS
use Beekeeper::Worker::Extension::SharedCache;
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 extension implements a locally mirrored shared cache: each worker keeps a copy of all cached data, and all copies are synced through the 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.
Due to propagation costs this cache does not scale very well. The limiting factor is the global rate of updates, which will cap around 5000 operations per second.
Thus this cache is suitable only for small data sets that do not change very often.
AUTHOR
José Micó, jose.mico@gmail.com
COPYRIGHT AND LICENSE
Copyright 2015-2023 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.