Changes between Version 5 and Version 6 of TracDev/CacheManager
- Timestamp:
- Aug 4, 2018, 10:44:32 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/CacheManager
v5 v6 1 1 = Caching and cache invalidation 2 2 3 Trac uses various caches at the component level, in order to speed-up costly tasks. Some examples are the ticket fields cache (#6436), the InterMapTxt cache, the user permission cache, and the oldest example being the Wiki page cache. 3 Trac uses caches at the component level, in order to speed-up costly tasks 4 * Ticket fields cache (#6436) 5 * InterMapTxt cache 6 * User permission cache 7 * Wiki page cache 4 8 5 Those caches are held at the level of `Component` instances. For a given class, there's one such instance per environment in any given server process. The first thing to take into account here is that those caches must be safely accessed and modified when accessed byconcurrent threads (in multi-threaded web front ends, that is).9 Those caches are held at the level of `Component` instances. For a given class, there's one such instance per environment in any given server process. The first thing to take into account is that those caches must be safely accessed and modified when used in concurrent threads (in multi-threaded web front ends, that is). 6 10 7 11 But because of the possibility of concurrent access at the underlying database level by '''multiple processes''', there is also a need to maintain a consistency and up-to-date status of those caches across all processes involved. Otherwise, you might do a change by the way of one request and the next request (even the GET following a redirect after your POST!) might be handled by a different server process which has a different "view" of the application state. 8 12 9 This doesn't even have to imply a multi-process server setup, as all what is needed is e.g.a modification of the database done using trac-admin.13 This doesn't even have to imply a multi-process server setup, as all what is needed is for example a modification of the database done using trac-admin. 10 14 11 15 == The Cache Manager 12 16 13 Starting with Trac [milestone:0.12] ( more precisely r8071), we introduced a !CacheManager component. That component is mostly transparent to the enddeveloper, which only has to deal with a decorator that can be used to create ''cached attributes''.17 Starting with Trac [milestone:0.12] (r8071), we introduced a !CacheManager component. That component is mostly transparent to the developer, which only has to deal with a decorator that can be used to create ''cached attributes''. 14 18 15 19 * '''Creating a cached attribute''' is done by defining a retrieval function and decorating it with the '''`@cached`''' decorator. For example, for the wiki page names: … … 41 45 42 46 ---- 43 See also TracDev/Proposals/CacheInvalidation for the history of the implementation details .47 See also TracDev/Proposals/CacheInvalidation for the history of the implementation details and th:CacheSystemPlugin for a plugin that implements caching for wiki pages.