caching with psr 6
play

Caching with PSR-6 Laravel Barcelona @laravelbcn @ hannesvdvreken - PowerPoint PPT Presentation

Caching with PSR-6 Laravel Barcelona @laravelbcn @ hannesvdvreken Hi, my name is Hannes. made with love.be 20 PSR-6 Caching in PHP anno 2016 1. Intro 2. Caching in 2015 3. Hello PSR-6 4. Practical


  1. Caching with PSR-6 Laravel Barcelona  @laravelbcn @ hannesvdvreken

  2. Hi, my name is Hannes.

  3. 🏄💼

  4. made with love.be 20 × 😎 

  5. PSR-6 Caching in PHP anno 2016

  6. 1. Intro 2. Caching in 2015 3. Hello PSR-6 4. Practical

  7. 1. Intro what is caching?

  8. WHAT IS CACHING Speeding up your app

  9. WHAT IS CACHING 1. Execute slow task 2.Remember result 3.Use stored value

  10. WHAT IS CACHING Should not cause app failure

  11. WHAT IS CACHING - EXAMPLES • HTTP Request • Slow DB call • Process image/zip/…

  12. WHAT IS CACHING Should not cause app failure

  13. WHAT IS CACHING geocode IP check cache store result check cache

  14. WHAT IS CACHING Should not cause app failure

  15. WHAT IS CACHING At different layers: User-Agent Webserver (Varnish/Nginx) Application Opcache

  16. WHAT IS CACHING Should not cause app failure

  17. 2. Caching in 2015 the state of caching (pre PSR-6)

  18. APPLICATION CACHING IN 2015 1. Libraries do it 2.Frameworks do it 3.Cache libs do it

  19. APPLICATION CACHING IN 2015 Frameworks & cache libs have their own: - interfaces - support for caching systems

  20. APPLICATION CACHING IN 2015 Adapters everywhere!

  21. APPLICATION CACHING IN 2015 If no adapter available - Write your own - Store in different cache stores

  22. 3. Hello PSR-6 what does that mean?

  23. INTRODUCING PSR-6 Finalised & accepted in December 2015

  24. INTRODUCING PSR-6 Repository - Entity

  25. INTRODUCING PSR-6 use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemInterface; $item = $pool->getItem($key); $item->getKey();

  26. INTRODUCING PSR-6 Lemme see that code

  27. INTRODUCING PSR-6 Don’t instantiate your own Items. $item = $pool->getItem(‘key’) ->set($value) ->expiresAfter(3600); $pool->save($item);

  28. INTRODUCING PSR-6 Item is an entity, it’s not immutable, but the Key is

  29. INTRODUCING PSR-6 CacheItemInterface has no getExpiresAt

  30. INTRODUCING PSR-6 Pool has support for multi-actions $pool->getItems($keys); $pool->saveDeferred($item); $pool->commit();

  31. INTRODUCING PSR-6 Repository - Entity model allows extensions

  32. INTRODUCING PSR-6 Cache features: - Stampede protection: Parallel incoming requests executing long process to update cache value

  33. INTRODUCING PSR-6 Cache features: - Stampede protection - Taggable cache $item->addTags(['cat-1']); $pool->clearTags(['cat-1']);

  34. INTRODUCING PSR-6 Cache features: - Stampede protection - Taggable cache - Hierarchical cache $pool->delete('tree/*');

  35. 4. Practical who uses it, and how can I use it?

  36. START USING IT Integration tests for implementations: cache/integration-tests

  37. START USING IT class PoolIntegrationTest extends CachePoolTest { public function createCachePool() { return new CachePool(); } }

  38. START USING IT - UPGRADE Upgrade paths

  39. START USING IT - UPGRADE Libraries

  40. START USING IT - UPGRADE Libraries (next major versions) have a PSR-6 caching decorator

  41. START USING IT - UPGRADE Frameworks

  42. START USING IT - UPGRADE Start using PSR-6 enabled libraries with adapters for current FW’s implementation.

  43. START USING IT - UPGRADE Example: Laravel PSR-6 bridge

  44. RECAP 1. Intro 2. Caching in 2015 3. Hello PSR-6 4. Practical

  45. Hello PSR-16

  46. Thank you! https:/ /joind.in/talk/xxxxx @laravelbcn @ hannesvdvreken

  47. Questions & discussions @laravelbcn @ hannesvdvreken

Recommend


More recommend