in reply to API rate limit using Cache::Mmap need help

While I am unfamiliar with Cache::Mmap, your error suggests that it is using Storable internally. You are trying to store a simple value, but Storable only works with references. Try changing your code like so: (untested)

my $key1 = "Test"; my $val1 = $cache->read($key1); print "read key1 count: ",$val1->{count},"\n"; $val1->{count}++; print "val1 count:",$val1->{count},"\n"; $cache->write($key1,$val1); $val1 = $cache->read($key1); print "read key1 count after write: ",$val1->{count},"\n";

Note the change: the values stored in the cache are now hashrefs. You could also use scalar references, reading them with $$val1 and incrementing with ${$val1}++.

Lastly, your code as written will not compile under strict. While it would not have caught this issue, good practice is to always use strict; and use warnings;.