craig campbell

  • added May 24, 2010 at 1:43 am
    When I work locally on projects I like to use symlinks for all of my shared libraries. It makes it way easier than having to manage a million different versions of the same files.

    Recently I was creating a tarball (.tar) archive to deploy somewhere using the -h option to follow symlinks like so:
    tar cvfh code.tar code

    I noticed that many of the symlinked files that were copied into the archive ended up being transformed into apple double files. Of course, this is quite annoying, and I wanted to get rid of them. I did some googling and found the answer buried somewhere on the internets so I thought I'd make it easier to find.
    read more
  • added April 14, 2010 at 2:34 am
    I realize most of the things I write about here are pretty technical so it feels a little bit strange to be breaking the mold, but I wanted to let people know about a very exciting project I have been working on in my spare time for nearly the past year.

    tonightly logo

    The inspiration came one night when I was out with some friends and we were wondering "What is there to do tonight?". We realized there was no one stop solution to answer this question, and every existing event site out there is cluttered and confusing. The goal for this project was to build a very simple, clean site that would provide event lists for any event happening on the current day.
    read more
  • 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 December 28, 2009 at 12:57 am
    updated May 24, 2010 at 1:03 am
    At work I have been working with memcache quite a bit and coming up with creative ways to cache stuff. Perhaps I will elaborate on some of these in later posts, but for now I think I will focus on one interesting issue I ran into using multiget.

    Using PECL Memcache extension the Memcache::get() method allows you to pass in a single key as a string or an array of keys to retrieve from cache. This can be very useful for retrieving lots of information with one request to memcache, however, there are a couple things to keep in mind. The first is something minor that I found annoying.

    Let's say you request array('item_1', 'item_2') from cache. If only item 1 is in cache then the resulting array will be something like this: array('item_1' => 'this is the value for item 1'). This means you have to actually check if a key exists in the resulting array or not in order to know how to proceed.

    The second thing had me banging my head against the wall for a short while since it was not possible to reproduce on a development environment. If you request multiple items from cache in one multiget request and the items requested are distributed over more than one server then they will not be returned in the same order that they were requested in.
    read more