1Data::ObjectDriver::DriUvseerr::CBoansterCiabcuhtee(d3D)Paetral::DOobcjuemcetnDtraitvieorn::Driver::BaseCache(3)
2
3
4
6 Data::ObjectDriver::Driver::BaseCache - parent class for caching object
7 drivers
8
11 Data::ObjectDriver::Driver::BaseCache provides behavior utilized for
12 all caching object drivers for use with Data::ObjectDriver. That
13 behavior is looking up requested objects in a cache, and falling back
14 to another Data::ObjectDriver for a cache miss.
15
17 Drivers based on Data::ObjectDriver::Driver::BaseCache support all
18 standard operations for Data::ObjectDriver object drivers (lookup,
19 search, update, insert, replace, remove, and fetch_data). BaseCache-
20 derived drivers also support:
21
22 "Data::ObjectDriver::Driver::BaseCache->new( %params )"
23 Creates a new instance of a BaseCache driver. Required members of
24 %params are:
25
26 · "cache"
27
28 The object with which to interface with the external cache. For
29 example, for the "Memcached" caching object driver, the value of
30 the "cache" member should be a "Cache::Memcached" object.
31
32 · "fallback"
33
34 The "Data::ObjectDriver" object driver to which to fall back when
35 the cache does not yet contain a requested object. The "fallback"
36 member is also the object driver to which updates and inserts are
37 passed.
38
39 "$driver->cache_key($class, $primary_key)"
40 Returns the cache key for an object of the given class with the given
41 primary key. The cache key is used with the external cache to identify
42 an object.
43
44 In BaseCache's implementation, the key is the class name and all the
45 column names of the primary key concatenated, separated by single
46 colons.
47
48 "$driver->get_multi_from_cache(@cache_keys)"
49 Returns the objects corresponding to the given cache keys, as
50 represented in the external cache.
51
52 "Data::ObjectDriver::Driver::BaseClass->Disabled([ $value ])"
53 Returns whether caches of the given class are disabled, first updating
54 the disabled state of drivers of the given class to $value, if given.
55 When a caching driver is disabled, all operations are automatically
56 passed through to the fallback object driver.
57
58 Note that, if you disable and reenable a caching driver, some of the
59 cached data may be invalid due to updates that were performed while the
60 driver was disabled not being reflected in the external cache.
61
63 When creating a caching driver from "BaseCache", the behavior for
64 interaction with the external cache (through the "cache" member of the
65 constructor) must be defined by implementing these methods:
66
67 "$driver->add_to_cache($cache_key, $obj_repr)"
68 Sets the cache entry for $cache_key to the given object representation.
69 This method is used when the corresponding object is being saved to the
70 database for the first time.
71
72 "$driver->update_cache($cache_key, $obj_repr)"
73 Sets the cache entry for $cache_key to the given object representation.
74 This method is used when the corresponding object already exists in the
75 database and is being saved.
76
77 "$driver->remove_from_cache($cache_key)"
78 Clears the given cache entry. This method is used when the
79 corresponding object is being deleted from the database.
80
81 "$driver->get_from_cache($cache_key)"
82 Returns the object corresponding to the given cache key, as it exists
83 in the external cache.
84
85 "$driver->inflate($class, $obj_repr)"
86 Returns an instance of $class containing the data in the representation
87 $obj_repr, as returned from the "get_from_cache" method.
88
89 In BaseCache's implementation, no operation is performed.
90 "get_from_cache" should itself return the appropriate instances of
91 "Data::ObjectDriver::BaseObject".
92
93 "$driver->deflate($obj)"
94 Returns a representation of the given "Data::ObjectDriver::BaseObject"
95 instance, suitable for passing to the "add_to_cache" and "update_cache"
96 methods.
97
98 In BaseCache's implementation, no operation is performed.
99 "add_to_cache" and "update_cache" should themselves accept
100 "Data::ObjectDriver::BaseObject" instances.
101
103 Data::ObjectDriver is free software; you may redistribute it and/or
104 modify it under the same terms as Perl itself.
105
107 Except where otherwise noted, Data::ObjectDriver is Copyright 2005-2006
108 Six Apart, cpan@sixapart.com. All rights reserved.
109
110
111
112perl v5.12.0 2010-D0a3t-a2:2:ObjectDriver::Driver::BaseCache(3)