Add upgrade docs

This commit is contained in:
Aaron Carlino 2018-05-30 16:00:41 +12:00
parent 4497f99d89
commit 8c56506a05

View File

@ -171,3 +171,33 @@ $gridField = new GridField('Teams', 'Teams', $this->Teams(), $config);
// method 2: removing GridField_ActionMenu from an existing GridField
$gridField->getConfig()->removeComponentsByType(GridField_ActionMenu);
```
### Versioned cache segmentation
The cache API now maintains separate cache pools for each versioned stage. This prevents users from caching draft data and then exposing it on the live stage.
```php
// Before:
$cache = Injector::inst()->get(CacheInterface::class . '.myapp');
Versioned::set_stage(Versioned::DRAFT);
$cache->set('my_key', 'Some draft content. Not for public viewing yet.');
Versioned::set_stage(Versioned::LIVE);
$cache->get('my_key'); // 'Some draft content. Not for public viewing yet'
// After:
$cache = Injector::inst()->get(CacheInterface::class . '.myapp');
Versioned::set_stage(Versioned::DRAFT);
$cache->set('my_key', 'Some draft content. Not for public viewing yet.');
Versioned::set_stage(Versioned::LIVE);
$cache->get('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.
```yaml
SilverStripe\Core\Injector\Injector:
Psr\SimpleCache\CacheInterface.myapp:
factory: SilverStripe\Core\Cache\CacheFactory
constructor:
namespace: "MyInsensitiveData"
args:
disable-container: true
```