CHI::Driver::Memory(3pm) | User Contributed Perl Documentation | CHI::Driver::Memory(3pm) |
CHI::Driver::Memory - In-process memory based cache
version 0.61
use CHI; my $hash = {}; my $cache = CHI->new( driver => 'Memory', datastore => $hash ); my $cache = CHI->new( driver => 'Memory', global => 1 ); my $cache = CHI->new( driver => 'Memory', global => 0 );
This cache driver stores data on a per-process basis. This is the fastest of the cache implementations, but data can not be shared between processes. Data will remain in the cache until cleared, expired, or the process dies.
To maintain the same semantics as other caches, references to data structures are deep-copied on set and get. Thus, modifications to the original data structure will not affect the data structure stored in the cache, and vice versa. See CHI::Driver::RawMemory for a faster memory cache that sacrifices this behavior.
When using this driver, the following options can be passed to CHI->new() in addition to the CHI. One of datastore or global must be specified, or else a warning (possibly an error eventually) will be thrown.
If this is set to false then datastore will be set to a new reference to a hash.
For size aware caches, this driver implements an 'LRU' policy, which discards the least recently used items first. This is the default policy.
CHI::Driver::RawMemory, CHI
Jonathan Swartz <swartz@pobox.com>
This software is copyright (c) 2021 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2021-10-15 | perl v5.32.1 |