Difference between revisions of "ARK2/Cache"
(→Cache) |
(→Cache) |
||
Line 3: | Line 3: | ||
Caching can greatly improve performance of ARK, especially for configuration and metadata, but also the data and database access. ARK provides a flexible caching system based on Doctrine Cache, Symphony Cache, and the PSR-6 Caching standard, and supporting filesystem, APCu, or Redis caches (others are possible but not officially supported). | Caching can greatly improve performance of ARK, especially for configuration and metadata, but also the data and database access. ARK provides a flexible caching system based on Doctrine Cache, Symphony Cache, and the PSR-6 Caching standard, and supporting filesystem, APCu, or Redis caches (others are possible but not officially supported). | ||
− | By default, ARK will use | + | By default, ARK will use APCu for caching if your server has APCu installed, otherwise a filesystem cache will be used. For high-volume sites and APIs, Redis is recommended using either Predis or PHPRedis. Redis can also be used as a Spatial cache to speed up spatial searches. |
== Configuration == | == Configuration == |
Revision as of 12:56, 19 July 2017
Cache
Caching can greatly improve performance of ARK, especially for configuration and metadata, but also the data and database access. ARK provides a flexible caching system based on Doctrine Cache, Symphony Cache, and the PSR-6 Caching standard, and supporting filesystem, APCu, or Redis caches (others are possible but not officially supported).
By default, ARK will use APCu for caching if your server has APCu installed, otherwise a filesystem cache will be used. For high-volume sites and APIs, Redis is recommended using either Predis or PHPRedis. Redis can also be used as a Spatial cache to speed up spatial searches.
Configuration
If caching is not explicitly configured in the site.json file, then ARK will check if APCu or APC is available, and if not will fall back to the filesystem. To fractionally improve performance, you can use site.json to explicitly set 'apc' or 'file'.
If using Redis you need to explicitly set site.json to use 'redis' and the url of the Redis instance.
If Debug mode is enabled, then the cache is disabled.
Implementation
ARK uses the Symfony Cache component for a PSR-6 compliant implementation. This also provides a bridge for the Doctrine ORM to use for caching.
Two caches are provided, the System and Application caches:
- System: An APCu/APC cache primarily for PHP compilable items or smaller static items such as config and metadata.
- App: A cache for application data.
These caches are accessed via the container:
- $app['cache.app'] or $app['cache']
- $app['cache.system']
- $app['cache.orm.app']
- $app['cache.orm.system']
The global Service object also provides access to the cache.
Commands
- cache::warmup - Warms-up the System cache
- cache::clear - Clears the System cache
- cache::refresh - Clears and warms-up the System cache
- doctrine cache commands?
Any cachable component should provide HTTP Kernel CacheWarmer and CacheClearer implementations and register these with the cache provider.