Edgewall Software

Changes between Version 5 and Version 6 of TracDev/CacheManager


Ignore:
Timestamp:
Aug 4, 2018, 10:44:32 AM (6 years ago)
Author:
figaro
Comment:

Further cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/CacheManager

    v5 v6  
    11= Caching and cache invalidation
    22
    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.
     3Trac 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
    48
    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 by concurrent threads (in multi-threaded web front ends, that is).
     9Those 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).
    610
    711But 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.
    812
    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.
     13This 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.
    1014
    1115== The Cache Manager
    1216
    13 Starting with Trac [milestone:0.12] (more precisely r8071), we introduced a !CacheManager component. That component is mostly transparent to the end developer, which only has to deal with a decorator that can be used to create ''cached attributes''.
     17Starting 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''.
    1418
    1519 * '''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:
     
    4145
    4246----
    43 See also TracDev/Proposals/CacheInvalidation for the history of the implementation details.
     47See also TracDev/Proposals/CacheInvalidation for the history of the implementation details and th:CacheSystemPlugin for a plugin that implements caching for wiki pages.