tractorcow / silverstripe-dynamiccache

Simple on the fly caching of dynamic content for Silverstripe
39 stars 27 forks source link

fixing example code #31

Closed spekulatius closed 8 years ago

jonom commented 8 years ago

While you're at it @spekulatius I wonder if we could improve this example:

class CacheCustomisation extends DynamicCacheExtension {
    public function updateEnabled(&$enabled) {
        // 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
        elseif (Session::get('StatusMessage')) $enabled = false;
    }
}

Verbose/inefficient for the sake of readability ;)

spekulatius commented 8 years ago

Hello @jonom ,

Thanks for your quick response! I have added your suggestions to the example. Seem sensible to cover those cases as well. @tractorcow are you happy with this?

Spek

tractorcow commented 8 years ago

This is an excellent contribution, thank you @spekulatius !