Introducing Frinkiac, The Simpsons Search Engine Built by Rackers

Combining their fondness for the show with some pretty incredible technical talent, Rackspace employees Paul Kehrer and Sean Schulte, together with designer Allie Young, built Frinkiac, a Simpsons-specific search engine (named for the show’s bespectacled Professor Frink), which indexes some three million screencaps from the show’s 15 seasons, matching each and every quote with the exact moment it was uttered.

.. “And when we suddenly had 3,000 concurrent users doing nearly 100 searches per second, things got rather compute intensive,” Kehrer said, understatedly.

python-redis-lock

Lock context manager implemented via redis SETNX/BLPOP

.. You would write your functions like this:

from django.core.cache import cache

def function():
    val = cache.get(key)
    if val:
        return val
    else:
        with cache.lock(key):
            val = cache.get(key)
            if val:
                return val
            else:
                # DO EXPENSIVE WORK
                val = ...

                cache.set(key, value)
                return val