Skip to content

Commit

Permalink
Merge pull request #31 from spekulatius/patch-1
Browse files Browse the repository at this point in the history
fixing example code
  • Loading branch information
Damian Mooyman committed Nov 22, 2015
2 parents 0eea7d0 + bef8c68 commit 4da9338
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,17 @@ mobile / non-mobile users (assuming silverstripe/mobile module is installed).

```php

CacheCustomisation extends DynamicCacheExtension {
class CacheCustomisation extends DynamicCacheExtension {
public function updateEnabled(&$enabled) {
if(Session::get('Uncachable') {
$enabled = false; // Disable caching for this request
}
// Disable caching for this request if a user is logged in
if (Member::currentUserID()) $enabled = false;

// Disable caching for this request if in dev mode
elseif (Director::isDev()) $enabled = false;

// Disable caching for this request if we have a message to display
// or the request shouldn't be cached for other reasons
elseif (Session::get('StatusMessage') || Session::get('Uncachable')) $enabled = false;
}

public function updateCacheKeyFragments(array &$fragments) {
Expand Down

0 comments on commit 4da9338

Please sign in to comment.