1Cache::CacheMetaData(3)User Contributed Perl DocumentatioCnache::CacheMetaData(3)
2
3
4
6 Cache::CacheMetaData -- data about objects in the cache
7
9 The CacheMetaData object is used by size aware caches to keep track of
10 the state of the cache and efficiently return information such as an
11 objects size or an ordered list of identifiers to be removed when a
12 cache size is being limited. End users will not normally use
13 CacheMetaData directly.
14
16 use Cache::CacheMetaData;
17
18 my $cache_meta_data = new Cache::CacheMetaData( );
19
20 foreach my $key ( $cache->get_keys( ) )
21 {
22 my $object = $cache->get_object( $key ) or
23 next;
24
25 $cache_meta_data->insert( $object );
26 }
27
28 my $current_size = $cache_meta_data->get_cache_size( );
29
30 my @removal_list = $cache_meta_data->build_removal_list( );
31
33 new( )
34 Construct a new Cache::CacheMetaData object
35
36 insert( $object )
37 Inform the CacheMetaData about the object $object in the cache.
38
39 remove( $key )
40 Inform the CacheMetaData that the object specified by $key is no
41 longer in the cache.
42
43 build_removal_list( )
44 Create a list of the keys in the cache, ordered as follows:
45
46 1) objects that expire now
47
48 2) objects expiring at a particular time, with ties broken by the
49 time at which they were least recently accessed
50
51 3) objects that never expire, sub ordered by the time at which they
52 were least recently accessed
53
54 NOTE: This could be improved further by taking the size into
55 account on accessed_at ties. However, this type of tie is unlikely
56 in normal usage.
57
58 build_object_size( $key )
59 Return the size of an object specified by $key.
60
62 get_cache_size
63 The total size of the objects in the cache
64
66 Cache::Cache, Cache::CacheSizer, Cache::SizeAwareCache
67
69 Original author: DeWitt Clinton <dewitt@unto.net>
70
71 Last author: $Author: dclinton $
72
73 Copyright (C) 2001-2003 DeWitt Clinton
74
75
76
77perl v5.36.0 2023-01-20 Cache::CacheMetaData(3)