├── LICENSE ├── composer.json ├── composer.lock ├── config ├── object-cache.php └── page-cache.php ├── dropins ├── advanced-cache.php └── object-cache.php ├── phpunit.xml └── src ├── Caches ├── ObjectCache.php └── PageCache.php ├── Console ├── ObjectCachePurgeCommand.php ├── ObjectCacheStatusCommand.php └── PageCachePurgeCommand.php ├── Facades └── ObjectCache.php └── Providers └── AcornCacheServiceProvider.php /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2020-present, Léo Colombaro 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "leocolomb/wp-acorn-cache", 3 | "description": "A cache manager powered by Laravel through Acorn.", 4 | "keywords": [ 5 | "wordpress-dropin", 6 | "wordpress-cache", 7 | "cache-object", 8 | "cache-page", 9 | "cache-advanced", 10 | "acorn", 11 | "laravel", 12 | "wordpress" 13 | ], 14 | "homepage": "https://github.com/LeoColomb/wp-acorn-cache", 15 | "license": "ISC", 16 | "authors": [ 17 | { 18 | "name": "Léo Colombaro", 19 | "homepage": "https://colombaro.fr/" 20 | } 21 | ], 22 | "require": { 23 | "php": "^8.1", 24 | "roots/acorn": "^v4.0" 25 | }, 26 | "require-dev": { 27 | "pestphp/pest": "^v1.20", 28 | "pestphp/pest-plugin-mock": "^v1.0", 29 | "squizlabs/php_codesniffer": "^3.5" 30 | }, 31 | "extra": { 32 | "acorn": { 33 | "providers": [ 34 | "LeoColomb\\WPAcornCache\\Providers\\AcornCacheServiceProvider" 35 | ] 36 | } 37 | }, 38 | "autoload": { 39 | "psr-4": { 40 | "LeoColomb\\WPAcornCache\\": "src/" 41 | } 42 | }, 43 | "autoload-dev": { 44 | "psr-4": { 45 | "LeoColomb\\WPAcornCache\\Tests\\": "tests/" 46 | } 47 | }, 48 | "config": { 49 | "sort-packages": true, 50 | "preferred-install": "dist", 51 | "allow-plugins": { 52 | "composer/installers": true, 53 | "pestphp/pest-plugin": true, 54 | "koodimonni/composer-dropin-installer": true 55 | } 56 | }, 57 | "minimum-stability": "beta", 58 | "scripts": { 59 | "lint": "phpcs", 60 | "lint:fix": "phpcbf", 61 | "test": "pest" 62 | }, 63 | "support": { 64 | "issues": "https://github.com/LeoColomb/wp-acorn-cache/issues" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /config/object-cache.php: -------------------------------------------------------------------------------- 1 | [ 16 | 'blog-details', 17 | 'blog-id-cache', 18 | 'blog-lookup', 19 | 'global-posts', 20 | 'networks', 21 | 'rss', 22 | 'sites', 23 | 'site-details', 24 | 'site-lookup', 25 | 'site-options', 26 | 'site-transient', 27 | 'users', 28 | 'useremail', 29 | 'userlogins', 30 | 'usermeta', 31 | 'user_meta', 32 | 'userslugs', 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Non-persistent cache groups 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Data belonging to these non-persistent groups are not stored, i.e. non persistent. 41 | | 42 | */ 43 | 44 | 'non-persistent' => [ 45 | 'counts', 46 | 'plugins', 47 | 'themes', 48 | ], 49 | 50 | ]; 51 | -------------------------------------------------------------------------------- /config/page-cache.php: -------------------------------------------------------------------------------- 1 | false, 14 | 15 | 'default_ttl' => 0, 16 | 17 | 'private_headers' => [ 18 | 'Authorization', 19 | 'Cookie' 20 | ], 21 | 22 | 'allow_reload' => false, 23 | 24 | 'allow_revalidate' => false, 25 | 26 | 'stale_while_revalidate' => 2, 27 | 28 | 'stale_if_error' => 60, 29 | 30 | 'trace_level' => 'none', 31 | 32 | 'trace_header' => 'X-Acorn-Cache', 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /dropins/advanced-cache.php: -------------------------------------------------------------------------------- 1 | handle(Request::instance()); 18 | -------------------------------------------------------------------------------- /dropins/object-cache.php: -------------------------------------------------------------------------------- 1 | boot(); 141 | $GLOBALS['wp_object_cache'] = ObjectCache::getFacadeRoot(); 142 | } 143 | 144 | /** 145 | * Replaces the contents of the cache with new data. 146 | * 147 | * @param int|string $key The key for the cache data that should be replaced. 148 | * @param mixed $data The new data to store in the cache. 149 | * @param string $group Optional. The group for the cache data that should be replaced. 150 | * Default empty. 151 | * @param int $expire Optional. When to expire the cache contents, in seconds. 152 | * Default 0 (no expiration). 153 | * @return bool False if original value does not exist, true if contents were replaced 154 | * @see ObjectCache::replace() 155 | */ 156 | function wp_cache_replace($key, $data, string $group = '', int $expire = 0) 157 | { 158 | return ObjectCache::replace($key, $data, $group, $expire); 159 | } 160 | 161 | /** 162 | * Saves the data to the cache. 163 | * Differs from wp_cache_add() and wp_cache_replace() in that it will always write data. 164 | * 165 | * @param int|string $key The cache key to use for retrieval later. 166 | * @param mixed $data The contents to store in the cache. 167 | * @param string $group Optional. Where to group the cache contents. Enables the same key 168 | * to be used across groups. Default empty. 169 | * @param int $expire Optional. When to expire the cache contents, in seconds. 170 | * Default 0 (no expiration). 171 | * @return bool True on success, false on failure. 172 | * @see ObjectCache::set() 173 | */ 174 | function wp_cache_set($key, $data, string $group = '', int $expire = 0) 175 | { 176 | return ObjectCache::set($key, $data, $group, $expire); 177 | } 178 | 179 | /** 180 | * Switches the internal blog ID. 181 | * This changes the blog id used to create keys in blog specific groups. 182 | * 183 | * @param int $blog_id Site ID. 184 | * @see ObjectCache::switch_to_blog() 185 | */ 186 | function wp_cache_switch_to_blog(int $blog_id) 187 | { 188 | ObjectCache::switchToBlog($blog_id); 189 | } 190 | 191 | /** 192 | * Adds a group or set of groups to the list of global groups. 193 | * 194 | * @param string|array $groups A group or an array of groups to add. 195 | * @see ObjectCache::addGlobalGroups() 196 | */ 197 | function wp_cache_add_global_groups($groups) 198 | { 199 | ObjectCache::addGlobalGroups($groups); 200 | } 201 | 202 | /** 203 | * Adds a group or set of groups to the list of non-persistent groups. 204 | * 205 | * @param string|array $groups A group or an array of groups to add. 206 | * @see ObjectCache::addNonPersistentGroups() 207 | */ 208 | function wp_cache_add_non_persistent_groups($groups) 209 | { 210 | ObjectCache::addNonPersistentGroups($groups); 211 | } 212 | 213 | /** 214 | * Retrieve a value from the object cache. If it doesn't exist, run the $callback to generate and 215 | * cache the value. 216 | * 217 | * @param string $key The cache key. 218 | * @param callable $callback The callback used to generate and cache the value. 219 | * @param string $group Optional. The cache group. Default is empty. 220 | * @param int $expire Optional. The number of seconds before the cache entry should expire. 221 | * Default is 0 (as long as possible). 222 | * @return mixed The value returned from $callback, pulled from the cache when available. 223 | */ 224 | function wp_cache_remember(string $key, callable $callback, string $group = '', int $expire = 0) 225 | { 226 | return ObjectCache::remember($key, $callback, $group, $expire); 227 | } 228 | 229 | /** 230 | * Retrieve and subsequently delete a value from the object cache. 231 | * 232 | * @param string $key The cache key. 233 | * @param string $group Optional. The cache group. Default is empty. 234 | * @param mixed $default Optional. The default value to return if the given key doesn't 235 | * exist in the object cache. Default is null. 236 | * 237 | * @return mixed The cached value, when available, or $default. 238 | */ 239 | function wp_cache_forget(string $key, string $group = '', $default = null) 240 | { 241 | return ObjectCache::forget($key, $group, $default); 242 | } 243 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests 10 | 11 | 12 | 13 | 14 | ./app 15 | ./src 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Caches/ObjectCache.php: -------------------------------------------------------------------------------- 1 | [ 44 | 'blog-details', 45 | 'blog-id-cache', 46 | 'blog-lookup', 47 | 'global-posts', 48 | 'networks', 49 | 'rss', 50 | 'sites', 51 | 'site-details', 52 | 'site-lookup', 53 | 'site-options', 54 | 'site-transient', 55 | 'users', 56 | 'useremail', 57 | 'userlogins', 58 | 'usermeta', 59 | 'user_meta', 60 | 'userslugs', 61 | ], 62 | 'non-persistent' => [ 63 | 'counts', 64 | 'plugins', 65 | 'themes', 66 | ] 67 | ]; 68 | 69 | /** 70 | * The blog prefix to prepend to the keys in non-global groups. 71 | * @var string 72 | */ 73 | private string $blogPrefix = ''; 74 | 75 | /** 76 | * Initialize 77 | * 78 | * @param array $config 79 | * @return void 80 | */ 81 | public function __construct(array $config = []) 82 | { 83 | $this->config = collect($this->defaultConfig)->merge($config); 84 | $this->switchToBlog(); 85 | } 86 | 87 | /** 88 | * Adds data to the cache if it doesn't already exist. 89 | * 90 | * @param string $key What to call the contents in the cache. 91 | * @param mixed $data The contents to store in the cache. 92 | * @param string $group Optional. Where to group the cache contents. Default 'default'. 93 | * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). 94 | * @return bool True on success, false if cache key and group already exist. 95 | */ 96 | public function add(string $key, mixed $data, string $group = 'default', int $expire = 0): bool 97 | { 98 | if (function_exists('wp_suspend_cache_addition') && wp_suspend_cache_addition()) { 99 | return false; 100 | } 101 | 102 | return Cache::add($this->buildKey($key, $group), $data, $expire); 103 | } 104 | 105 | /** 106 | * Replaces the contents in the cache, if contents already exist. 107 | * 108 | * @since 2.0.0 109 | * 110 | * @param string $key What to call the contents in the cache. 111 | * @param mixed $data The contents to store in the cache. 112 | * @param string $group Optional. Where to group the cache contents. Default 'default'. 113 | * @param int $expire Optional. When to expire the cache contents. Default 0 (no expiration). 114 | * @return bool False if not exists, true if contents were replaced. 115 | */ 116 | public function replace(string $key, mixed $data, string $group = 'default', int $expire = 0): bool 117 | { 118 | if (! Cache::has($this->buildKey($key, $group))) { 119 | return false; 120 | } 121 | 122 | return Cache::put($this->buildKey($key, $group), $data, $expire); 123 | } 124 | 125 | /** 126 | * Removes the contents of the cache key in the group. 127 | * 128 | * If the cache key does not exist in the group, then nothing will happen. 129 | * 130 | * @since 2.0.0 131 | * 132 | * @param string $key What the contents in the cache are called. 133 | * @param string $group Optional. Where the cache contents are grouped. Default 'default'. 134 | * @return bool False if the contents weren't deleted and true on success. 135 | */ 136 | public function delete(string $key, string $group = 'default'): bool 137 | { 138 | return Cache::forget($this->buildKey($key, $group)); 139 | } 140 | 141 | /** 142 | * Clears the object cache of all data. 143 | * 144 | * @since 2.0.0 145 | * 146 | * @return true Always returns true. 147 | */ 148 | public function flush(): bool 149 | { 150 | return Cache::flush(); 151 | } 152 | 153 | /** 154 | * Retrieves the cache contents, if it exists. 155 | * 156 | * The contents will be first attempted to be retrieved by searching by the 157 | * key in the cache group. If the cache is hit (success) then the contents 158 | * are returned. 159 | * 160 | * On failure, the number of cache misses will be incremented. 161 | * 162 | * @since 2.0.0 163 | * 164 | * @param string $key The key under which the cache contents are stored. 165 | * @param string $group Optional. Where the cache contents are grouped. Default 'default'. 166 | * @param bool $force Optional. Unused. Whether to force an update of the local cache 167 | * from the persistent cache. Default false. 168 | * @param bool $found Optional. Whether the key was found in the cache (passed by reference). 169 | * Disambiguates a return of false, a storable value. Default null. 170 | * @return mixed The cache contents on success, false on failure to retrieve contents. 171 | */ 172 | public function get(string $key, string $group = 'default', bool $force = false, bool &$found = null): mixed 173 | { 174 | $found = true; 175 | 176 | return Cache::get($this->buildKey($key, $group), function () use (&$found) { 177 | $found = false; 178 | }); 179 | } 180 | 181 | /** 182 | * Retrieves multiple values from the cache in one call. 183 | * 184 | * @since 5.5.0 185 | * 186 | * @param array $keys Array of keys under which the cache contents are stored. 187 | * @param string $group Optional. Where the cache contents are grouped. Default 'default'. 188 | * @param bool $force Optional. Whether to force an update of the local cache 189 | * from the persistent cache. Default false. 190 | * @return array Array of values organized into groups. 191 | */ 192 | public function getMultiple(array $keys, string $group = 'default', bool $force = false): array 193 | { 194 | $values = []; 195 | 196 | foreach ($keys as $key) { 197 | $values[$key] = $this->get($key, $group); 198 | } 199 | 200 | return $values; 201 | } 202 | 203 | /** 204 | * Sets the data contents into the cache. 205 | * 206 | * The cache contents are grouped by the $group parameter followed by the 207 | * $key. This allows for duplicate IDs in unique groups. Therefore, naming of 208 | * the group should be used with care and should follow normal function 209 | * naming guidelines outside of core WordPress usage. 210 | * 211 | * The $expire parameter is not used, because the cache will automatically 212 | * expire for each time a page is accessed and PHP finishes. The method is 213 | * more for cache plugins which use files. 214 | * 215 | * @since 2.0.0 216 | * 217 | * @param string $key What to call the contents in the cache. 218 | * @param mixed $data The contents to store in the cache. 219 | * @param string $group Optional. Where to group the cache contents. Default 'default'. 220 | * @param ?int $expire Not Used. 221 | * @return true Always returns true. 222 | */ 223 | public function set(string $key, mixed $data, string $group = 'default', int $expire = null): bool 224 | { 225 | if (in_array($group, $this->config->get('non-persistent'))) { 226 | return true; 227 | } 228 | 229 | return Cache::put($this->buildKey($key, $group), $data, $expire); 230 | } 231 | 232 | /** 233 | * Increments numeric cache item's value. 234 | * 235 | * @since 3.3.0 236 | * 237 | * @param string $key The cache key to increment 238 | * @param int $offset Optional. The amount by which to increment the item's value. Default 1. 239 | * @param string $group Optional. The group the key is in. Default 'default'. 240 | * @return int|false The item's new value on success, false on failure. 241 | */ 242 | public function incr(string $key, int $offset = 1, string $group = 'default'): int|false 243 | { 244 | if (in_array($group, $this->config->get('non-persistent'))) { 245 | return false; 246 | } 247 | 248 | Cache::increment($this->buildKey($key, $group), $offset); 249 | 250 | return Cache::get($this->buildKey($key, $group)); 251 | } 252 | 253 | /** 254 | * Decrements numeric cache item's value. 255 | * 256 | * @since 3.3.0 257 | * 258 | * @param string $key The cache key to decrement. 259 | * @param int $offset Optional. The amount by which to decrement the item's value. Default 1. 260 | * @param string $group Optional. The group the key is in. Default 'default'. 261 | * @return int|false The item's new value on success, false on failure. 262 | */ 263 | public function decr(string $key, int $offset = 1, string $group = 'default'): int|false 264 | { 265 | if (in_array($group, $this->config->get('non-persistent'))) { 266 | return false; 267 | } 268 | 269 | Cache::decrement($this->buildKey($key, $group), $offset); 270 | 271 | return Cache::get($this->buildKey($key, $group)); 272 | } 273 | 274 | /** 275 | * Retrieve a value from the object cache. If it doesn't exist, run the $callback to generate and 276 | * cache the value. 277 | * 278 | * @param string $key The cache key. 279 | * @param callable $callback The callback used to generate and cache the value. 280 | * @param string $group Optional. The cache group. Default is empty. 281 | * @param int|null $expire Optional. The number of seconds before the cache entry should expire. 282 | * Default is 0 (as long as possible). 283 | * @return mixed The value returned from $callback, pulled from the cache when available. 284 | */ 285 | public function remember(string $key, callable $callback, string $group = '', int $expire = null): mixed 286 | { 287 | return Cache::remember($this->buildKey($key, $group), $expire, $callback); 288 | } 289 | 290 | /** 291 | * Retrieve and subsequently delete a value from the object cache. 292 | * 293 | * @param string $key The cache key. 294 | * @param string $group Optional. The cache group. Default is empty. 295 | * @param mixed $default Optional. The default value to return if the given key doesn't 296 | * exist in the object cache. Default is null. 297 | * @return mixed The cached value, when available, or $default. 298 | */ 299 | public function forget(string $key, string $group = '', mixed $default = null): mixed 300 | { 301 | return Cache::pull($this->buildKey($key, $group), $default); 302 | } 303 | 304 | /** 305 | * In multisite, switch blog prefix when switching blogs. 306 | * 307 | * @param ?int $blogId Blog ID. 308 | */ 309 | public function switchToBlog(?int $blogId = null): void 310 | { 311 | if (function_exists('is_multisite') && is_multisite()) { 312 | $this->blogPrefix = ($blogId ?: get_current_blog_id()) . ':'; 313 | } 314 | } 315 | 316 | /** 317 | * Sets the list of groups. 318 | * 319 | * @param string $category The category of the list of groups. 320 | * @param array|string $groups List of groups that are global. 321 | */ 322 | protected function addGroups(string $category, array|string $groups): void 323 | { 324 | $this->config = $this->config->mergeRecursive([$category => Arr::wrap($groups)]); 325 | } 326 | 327 | /** 328 | * Sets the list of global groups. 329 | * 330 | * @param array|string $groups List of groups that are global. 331 | */ 332 | public function addGlobalGroups(array|string $groups): void 333 | { 334 | $this->addGroups('global', $groups); 335 | } 336 | 337 | /** 338 | * Sets the list of groups not to be cached. 339 | * 340 | * @param array|string $groups List of groups that are to be non-persistent. 341 | */ 342 | public function addNonPersistentGroups(array|string $groups): void 343 | { 344 | $this->addGroups('non-persistent', $groups); 345 | } 346 | 347 | /** 348 | * Builds a key for the cached object using the prefix, group and key. 349 | * 350 | * @param string $key The key under which to store the value. 351 | * @param string $group The group value appended to the $key. 352 | * @return string 353 | */ 354 | protected function buildKey(string $key, string $group = 'default'): string 355 | { 356 | if (empty($group)) { 357 | $group = 'default'; 358 | } 359 | 360 | $prefix = in_array($group, $this->config->get('global')) ? '' : $this->blogPrefix; 361 | 362 | return "{$prefix}{$group}:{$key}"; 363 | } 364 | 365 | /** 366 | * @param string $name 367 | * @return mixed 368 | */ 369 | public function __get(string $name): mixed 370 | { 371 | return $this->config->get(Str::slug(Str::remove('_groups', $name))); 372 | } 373 | } 374 | -------------------------------------------------------------------------------- /src/Caches/PageCache.php: -------------------------------------------------------------------------------- 1 | kernel = $kernel; 33 | $this->surrogate = $surrogate; 34 | $this->options = $options ?? []; 35 | 36 | if ($cache instanceof StoreInterface) { 37 | $this->store = $cache; 38 | } elseif (is_array($cache)) { 39 | $this->options = $cache; 40 | } elseif (null !== $cache && !\is_string($cache)) { 41 | throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a string or a SurrogateInterface, "%s" given.', __METHOD__, get_debug_type($cache))); 42 | } else { 43 | $this->cacheDir = $cache; 44 | } 45 | 46 | if (null === $options && $kernel->isDebug()) { 47 | $this->options = ['debug' => true]; 48 | } 49 | 50 | if ($this->options['debug'] ?? false) { 51 | $this->options += ['stale_if_error' => 0]; 52 | } 53 | 54 | parent::__construct($kernel, $this->createStore(), $this->surrogate, $this->options); 55 | } 56 | 57 | /** 58 | * {@inheritdoc} 59 | */ 60 | protected function forward(Request $request, bool $catch = false, Response $entry = null): Response 61 | { 62 | $this->getKernel()->boot(); 63 | $this->getKernel()->getContainer()->set('cache', $this); 64 | 65 | return parent::forward($request, $catch, $entry); 66 | } 67 | 68 | /** 69 | * @return Store|StoreInterface 70 | */ 71 | protected function createStore(): Store|StoreInterface 72 | { 73 | return $this->store ?? new Store($this->cacheDir ?: $this->kernel->getCacheDir() . '/http_cache'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Console/ObjectCachePurgeCommand.php: -------------------------------------------------------------------------------- 1 | hasArgument('key')) { 34 | $cache->delete($this->argument('key')); 35 | } else { 36 | $cache->flush(); 37 | } 38 | 39 | $this->info('Purged'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Console/ObjectCacheStatusCommand.php: -------------------------------------------------------------------------------- 1 | add('status', 'ok'); 34 | $valid = $cache->get('status') === 'ok'; 35 | } catch (\Exception $exception) { 36 | $this->error('Status: Error'); 37 | $this->alert($exception); 38 | 39 | return; 40 | } 41 | 42 | if (!$valid) { 43 | $this->warn('Status: Unexpected behavior'); 44 | 45 | return; 46 | } 47 | 48 | $this->info('Status: Connected'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Console/PageCachePurgeCommand.php: -------------------------------------------------------------------------------- 1 | hasArgument('url')) { 34 | $cache->getStore()->purge($this->argument('url')); 35 | } else { 36 | $cache->getStore()->cleanup(); 37 | } 38 | 39 | $this->info('Purged'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Facades/ObjectCache.php: -------------------------------------------------------------------------------- 1 | app->singleton(ObjectCache::class, function () { 22 | return new ObjectCache($this->app->config->get('object-cache')); 23 | }); 24 | $this->app->singleton(PageCache::class, function () { 25 | return new PageCache(app('http'), $this->app->config->get('page-cache')); 26 | }); 27 | } 28 | 29 | /** 30 | * Bootstrap any application services. 31 | * 32 | * @return void 33 | */ 34 | public function boot(): void 35 | { 36 | $this->app->make(ObjectCache::class); 37 | 38 | $this->publishes([ 39 | dirname(__DIR__, 2) . '/config/object-cache.php' => $this->app->configPath('object-cache.php'), 40 | dirname(__DIR__, 2) . '/config/page-cache.php' => $this->app->configPath('page-cache.php'), 41 | ]); 42 | 43 | if ($this->app->runningInConsole()) { 44 | $this->commands([ 45 | ObjectCacheStatusCommand::class, 46 | ObjectCachePurgeCommand::class, 47 | PageCachePurgeCommand::class, 48 | ]); 49 | } 50 | } 51 | } 52 | --------------------------------------------------------------------------------