age Cache::Memcached::AnyEvent::Serializer::JSON;
use strict;
use Module::Runtime ();
BEGIN {
my $backend;
foreach my $module (qw(JSON JSON::XS JSON::PP)) {
eval { Module::Runtime::req
"Could not find JSON backend module";
}
{
no strict 'refs';
*_encode_json = \&{"${backend}::encode_json"};
*_decode_json = \&{"${backend}::decode_json"};
}
}
sub
{$_[1]} = _encode_json(${$_[1]});
${$_[2]} = bytes::length(${$_[1]});
${$_[3]} |= Cache::Memcached::AnyEvent::F_SERIALIZE();
}
sub deserialize {
${$_[1]} = _decode_json(${$_[1]});
}
1;