Update documentation

This commit is contained in:
Damian Mooyman 2018-06-05 11:34:46 +12:00
parent 85a712e1c9
commit f4411df75c
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 17 additions and 3 deletions

View File

@ -90,6 +90,20 @@ e.g. by including the `LastEdited` value when caching `DataObject` results.
// set all caches to 3 hours // set all caches to 3 hours
SS_Cache::set_cache_lifetime('any', 60*60*3); SS_Cache::set_cache_lifetime('any', 60*60*3);
### Versioned cache segmentation
`SS_Cache` segments caches based on the versioned reading mode. This prevents developers
from caching draft data and then accidentally exposing it on the live stage without potentially
required authorisation checks. This segmentation is automatic for all caches generated using
`SS_Cache::factory` method.
Data that is not content sensitive can be cached across stages by simply opting out of the
segmented cache with the `disable-segmentation` argument.
```php
$cache = SS_Cache::factory('myapp', 'Output', array('disable-segmentation' => true));
```
## Alternative Cache Backends ## Alternative Cache Backends
By default, SilverStripe uses a file-based caching backend. By default, SilverStripe uses a file-based caching backend.

View File

@ -19,8 +19,8 @@ $cache->save('Some draft content. Not for public viewing yet.', 'my_key');
Versioned::set_reading_mode('Stage.Live'); Versioned::set_reading_mode('Stage.Live');
$cache->load('my_key'); // null $cache->load('my_key'); // null
``` ```
Data that is not content sensitive can be cached across stages by simply opting out of the segmented cache with the `disable-container` argument. Data that is not content sensitive can be cached across stages by simply opting out of the segmented cache with the `disable-segmentation` argument.
```php ```php
$cache = SS_Cache::factory('myapp', 'Output', array('disable-container' => true)); $cache = SS_Cache::factory('myapp', 'Output', array('disable-segmentation' => true));
``` ```