1CHI::Driver::Memory(3)User Contributed Perl DocumentationCHI::Driver::Memory(3)
2
3
4
6 CHI::Driver::Memory - In-process memory based cache
7
9 version 0.44
10
12 use CHI;
13
14 my $hash = {};
15 my $cache = CHI->new( driver => 'Memory', datastore => $hash );
16
17 my $cache = CHI->new( driver => 'Memory', global => 1 );
18
20 This cache driver stores data on a per-process basis. This is the
21 fastest of the cache implementations, but data can not be shared
22 between processes. Data will remain in the cache until cleared,
23 expired, or the process dies.
24
25 To maintain the same semantics as other caches, references to data
26 structures are deep-copied on set and get. Thus, modifications to the
27 original data structure will not affect the data structure stored in
28 the cache, and vica versa. See CHI::Driver::RawMemory for a faster
29 memory cache that sacrifices this behavior.
30
32 When using this driver, the following options can be passed to
33 CHI->new() in addition to the CHI. One of datastore or global must be
34 specified, or else a warning (possibly an error eventually) will be
35 thrown.
36
37 datastore [HASH]
38 A hash to be used for storage. Within the hash, each namespace is
39 used as a key to a second-level hash. This hash may be passed to
40 multiple CHI::Driver::Memory constructors.
41
42 global [BOOL]
43 Use a standard global datastore. Multiple caches created with this
44 flag will see the same data. Before 0.21, this was the default
45 behavior; now it must be specified explicitly (to avoid
46 accidentally sharing the same datastore in unrelated code).
47
49 For CHI/SIZE AWARENESS caches, this driver implements an 'LRU' policy,
50 which discards the least recently used items first. This is the default
51 policy.
52
54 CHI::Driver::RawMemory, CHI
55
57 Jonathan Swartz <swartz@pobox.com>
58
60 This software is copyright (c) 2011 by Jonathan Swartz.
61
62 This is free software; you can redistribute it and/or modify it under
63 the same terms as the Perl 5 programming language system itself.
64
65
66
67perl v5.12.3 2011-03-17 CHI::Driver::Memory(3)