Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Typo3 Workshop @ T3DD19 - Make the cache work for you

Typo3 Workshop @ T3DD19 - Make the cache work for you

A step by step primer to add your own caching logic to your extbase extension.
Code is available on Gihub: https://github.com/foppelfb/workshop/
the Steps are available as Branches https://github.com/foppelfb/workshop/branches

Frank Berger

August 03, 2019

More Decks by Frank Berger

Other Decks in Programming


  1. • Frank Berger (Greybeard) • Head of Engineering
 B-FACTOR Sudhaus7

    • started 1996 as Unix Systemadministrator who also programs (aka „Devops“) Sudhaus7 A SHORT NOTE ABOUT ME
  2. $cache = new CacheManager(); // Generate key $key = ‘something-unique-to-identify-this-peace-of-content’;

    // fetch data if (($data = $cache->get($key) === false) { // do what needs to be cached $data = timeAndResourceExpensiveOperation(); // define tags $tags[‘tag_1’,’pageId_x’]; // store data (forever) $cache->set($key,$data,$tags,0) } // use data return $data; Sudhaus7 GENERAL PATTERN
  3. Sudhaus7 SOME TERMINOLOGY • cacheKey - a unique identifier which

    considers all necessary 
 context that defines the current state and result • tags - related information on which this cache should be purged • cacheFrontend - the mechanism which handles the data • cacheBackend - the mechanism which stores the data
  4. WHAT MAKES A KEY? • Datatype - What is it?

    • Plugin - Where does it run in? • Source - where is it read from? • Target - in what context is it displayed? • Page • Column • Language • Actor - who is using the website? Sudhaus7
  5. SETTING UP THE WORKSHOP ENVIRONMENT • git clone https://github.com/foppelfb/workshop.git

    download zip from here:
 https://github.com/foppelfb/workshop/archive/master.zip • cd workshop • ddev start • ddev composer install • http://workshop.ddev.site:8080/ • User: admin Password: password Sudhaus7
  6. Sudhaus7 AVAILABLE EXTRA COMMANDS • ddev composer killcache
 (will flush

    the cache) • ddev composer t3update
 (will call install:extensionsetupifpossible)
  7. Sudhaus7 GOOD TO KNOW • tag [pageId_$pid] will be purged

    when the cache-clear 
 for the page with this pid is called • an Extbase Controller Action can return the content. If it does 
 not return the content, $this->view->render() will be called.
  8. Frank Berger Sudhaus7 (eine Marke der B-FACTOR GmbH) [email protected] Twitter:

    @foppelfb https://github.com/foppelfb Sudhaus7 THANK YOU!