Your SlideShare is downloading. ×
  • Like


Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply



Cache invalidation for the lazy coder

Cache invalidation for the lazy coder

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Who
  • 2. Who Kevin van Zonneveld t: @kvz e: • cake: Learned from @felixge while working on Now building backend & admin in it • like: Reusable code & to Automate everything • startup:
  • 3. What
  • 4. What Eventcache Cache invalidation for the lazy coder
  • 5. What What I use it for • Caching model data • Caching slow functions • Auto-Purging when an involved model saves / deletes
  • 6. What Features • Invalidation Obviously • Doesn’t care about your PHP Framework I use CakePHP, but it’s not tied to that • “Magic function-wrapper” Allows for easy integration in your app.. I’ll show you in a minute! • Easy access EventCache::read(); // like Cake’s Cache::read(); • Speed Eventcache additionally uses inside-process memory This way the cache backend is only hit once per key per process • Supports multiple backends Apc, File, Memcache, Redis
  • 7. Why #1 Why Caching
  • 8. Why Simple
  • 9. Why fastness == pretty awesome Cache adds speed without dropping a sweat
  • 10. Why #2 Why Eventcache (I already use CakePHP/Custom caching)
  • 11. Why Well
  • 12. Why • Caching is easy • Invalidation is hard “There are only 2 hard problems in Computer Science: Cache invalidation, Naming things, Off-by-one errors”
  • 13. Why Eventcache solves 2 of those problems: • Cache invalidation - Sorry, you are on your own with Naming & Off-by-one errors
  • 14. How
  • 15. How When you store a key • Also register what events will trigger it’s removal • Optionally specify other conditions that have to be met e.g.: parent model’s timestamp, customer_id • Eventcache takes care of invalidation
  • 16. How The Code
  • 17. How Initialize Do a vendor import in your bootstrap Optionally config:
  • 18. How The normal flow ttl didn’t purge nickname. you didn’t purge nickname. User->afterSave did
  • 19. How Tie in with your app Fair enough, Eventcache needs to know about your events ..but that’s all there is to it
  • 20. How Magic function-wrapper Add caching to an existing function with minimal effort -before- just some CPU intensive function
  • 21. How Magic function-wrapper Add caching to an existing function with minimal effort -after- By adding 4 lines of code, the function is now cached
  • 22. How More options
  • 23. How What’s needed • More fine-grained events You could do this yourself, but it would be nice if Eventcache supported events with arguments so you never purge more than needed • Adapters Currently, the APC adapter has some issues • Your tender, love & care Exposing to more programmers & environments to will surface bugs & feature requests to make it perfect
  • 24. Where
  • 25. Where Here: • Fork • Follow • Subscribe • Mail • Check
  • 26. Questions?
  • 27. Thank you!