1 | <?php |
||
16 | class PostRelatedCacheManager extends BasicCacheManager |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * @type string |
||
21 | */ |
||
22 | const POST_CACHE_PREFIX = 'ee_cache_post_'; |
||
23 | |||
24 | /** |
||
25 | * wp-option option_name for tracking post related cache |
||
26 | * |
||
27 | * @type string |
||
28 | */ |
||
29 | const POST_CACHE_OPTIONS_KEY = 'ee_post_cache'; |
||
30 | |||
31 | |||
32 | |||
33 | /** |
||
34 | * PostRelatedCacheManager constructor. |
||
35 | * |
||
36 | * @param CacheStorageInterface $cache_storage |
||
37 | */ |
||
38 | public function __construct(CacheStorageInterface $cache_storage) |
||
43 | |||
44 | |||
45 | |||
46 | /** |
||
47 | * returns a string that will be prepended to all cache identifiers |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public function cachePrefix() |
||
55 | |||
56 | |||
57 | |||
58 | /** |
||
59 | * If you are caching content that pertains to a Post of any type, |
||
60 | * then it is recommended to pass the post id and cache id prefix to this method |
||
61 | * so that it can be added to the post related cache tracking. |
||
62 | * Then, whenever that post is updated, the cache will automatically be deleted, |
||
63 | * which helps to ensure that outdated cache content will not be served |
||
64 | * |
||
65 | * @param int $post_ID [required] |
||
66 | * @param string $id_prefix [required] Appended to all cache IDs. Can be helpful in finding specific cache types. |
||
67 | * May also be helpful to include an additional specific identifier, |
||
68 | * such as a post ID as part of the $id_prefix so that individual caches |
||
69 | * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
||
70 | * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
||
71 | */ |
||
72 | public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix) |
||
84 | |||
85 | |||
86 | |||
87 | /** |
||
88 | * callback hooked into the WordPress "save_post" action |
||
89 | * deletes any cache content associated with the post |
||
90 | * |
||
91 | * @param int $post_ID [required] |
||
92 | */ |
||
93 | public function clearPostRelatedCache($post_ID) |
||
105 | |||
106 | |||
107 | } |
||
108 | // End of file PostRelatedCacheManager.php |
||
109 | // Location: EventEspresso\core\services\cache/PostRelatedCacheManager.php |