Difference between revisions of "ARK2/Cache"

From ARK
Jump to: navigation, search
(Commands)
(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 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.
+
By default, ARK will use APC/APCu for caching if your server has APCu/APC 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 ==
  
If caching is not explicitly configured in the site.json file, then ARK will check if APCu is available, and if not will fall back to the filesystem. To fractionally improve performance, you can use site.json to explicitly set 'apcu' or 'file'.
+
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 using Redis you need to explicitly set site.json to use 'redis' and the url of the Redis instance.
  
If Debug mode is enabled, the the cache is disabled.
+
If Debug mode is enabled, then the cache is disabled.
  
 
== Implementation ==
 
== Implementation ==
  
The Doctrine ORM requires the use of the Doctrine Cache component to cache database access, however it is not PSR-6 compliant and is primarily designed for database caching. The Symfony Cache component provides a PSR-6 implementation designed for a wider use case, and provides a bridge to the Doctrine Cache. ARK creates a Doctrine Cache object which is then passed to the Symfony Cache.
+
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:
 
Two caches are provided, the System and Application caches:
* System: Not persistent, not distributed, intended for static config, metadata, etc
+
* System: An APCu/APC cache primarily for PHP compilable items or smaller static items such as config and metadata.
* App: Persistent, Distributed,
+
* App: A cache for application data.
  
 
These caches are accessed via the container:
 
These caches are accessed via the container:
Line 27: Line 27:
 
* $app['cache.orm.system']
 
* $app['cache.orm.system']
  
The Service object also provides access to the  
+
The global Service object also provides access to the cache.
  
 
== Commands ==
 
== Commands ==
  
* cache::warmup - warms-up the System cache
+
* cache::warmup - Warms-up the System cache
* cache::clear - clears the System cache
+
* cache::clear - Clears the System cache
* cache::refresh - clears and warmsup the System cache
+
* cache::refresh - Clears and warms-up the System cache
 
* doctrine cache commands?
 
* doctrine cache commands?
  
 
Any cachable component should provide HTTP Kernel CacheWarmer and CacheClearer implementations and register these with the cache provider.
 
Any cachable component should provide HTTP Kernel CacheWarmer and CacheClearer implementations and register these with the cache provider.

Revision as of 10:22, 28 December 2016

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 APC/APCu for caching if your server has APCu/APC 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.