-
added March 9, 2010 at 2:27 am
A while back I wrote about a way to keep data valid across multiple pages by invalidating cache keys. I have since thought of a better way to handle this.
The basic idea is that anytime you have child objects related to a parent object you can use a property of the parent object to invalidate the children. To make this more clear let's revisit the original problem: You are building a blog with a lot of users where each user posts a bunch of articles. The articles are paginated and cached per page. If the user adds a new article, all the items on the page will shift and we need a way to invalidate all the pages in cache.
The approach mentioned in my previous article involved having a namespace key that would store a random integer which would then be incremented when there is an update. This has a few problems:
read more -
added May 27, 2009 at 12:02 am
updated March 9, 2010 at 2:30 am
UPDATED 09 MAR 2010 SEE THIS POST
I have been so incredibly busy lately that I have not had anytime to write here. Anyway I just wanted to take some time to talk about something cool I have been doing for a project I have been working on outside of work.
By now everyone knows what Memcached is so I won't bore you with an introduction. Basically it is an insanely simple caching system designed to eliminate load on the database.
While in an ideal world you would just throw cache on everything and watch your application scale to infinity and beyond, things aren't always that simple. The problem I'm going to show you today has to do with pagination and cached database queries. I will try to make this pretty straightforward so anyone can follow.
read more -
added April 3, 2009 at 10:41 pm
Just when you thought I had run out of material to write about I am back! I have a few topics still lined up, but I have been so busy that I haven't had time to write anything.
The project I have been working on at work has lots of pagination in it, and the other day I was really frustrated with how difficult it was to do simple pagination and how many lines of code it took in the controller. Here I am going to present to you a pagination class I wrote and a usage example.
I am aware that there is a Zend_Pagination class in Zend Framework, but I'm not crazy about it. It offers some nice view helpers to draw pagination on a page, however, it is over 900 lines long, contains a lot of code you probably will never need, and is missing simple functions that you may need such as determining the page offset or the first and last item on the current page.
read more