by Garrick van BurenComments Off on How To Cache Highly Dynamic Data in Rails with Memcache – Part 1
There are a number of ways increase Ruby on Rails performance through caching. Caching works because things don’t change….or don’t change frequently.
In Cullect, almost everything is dynamic, even Cullect’s HTML presentation format has 3 different states depending on access privileges and there are 8 other presentation formats available.
The standard page, action, and fragment caching make less sense when the ‘heaviest’ data are also the most dynamic – the feed items.
For the feed items, I’m using a building a custom memcached name-value-pair holding 10 attributes describing the request as the key name and the items themselves as the key value.
From the ‘show’ action in my controller:
key = "
Notice the first attribute in the key is the total number of items within a specific Cullect Reading List – which will change when a feed updates or an item is hidden – automatically expiring stale caches.
Then, I check the cache for the key and pull the items from the cache if it exists.
@allitems = Cache.get(key)
If there’s no key in the cache, I do the query and put the retrieved items into the cache.
@allitems = get_items(attribute_1, attribute_2, attribute_3, attribute_4, etc)
Cache.put key, @allitems
While this speeds up subsequent requests, there’s still the question of speeding up the initial request. I’ll save that for part 2.
For a productive work-related phone conversation, I need internet access anyway, so this works perfect. Additionally, if I’m not within a wifi network, I’m probably driving or otherwise not able to talk.
But what about this next time I need to purchase a mobile phone service plan? Sometime in 2010.
by Garrick van BurenComments Off on First Crack 111. Patricia Cumbie’s ‘Where People Like Us Live’
From the unpublished First Crack archives, I bring you a conversation I recorded in July 2007 with Minneapolis novelist, Patricia Crumbie on her then – yet to be published – young adult novel, Where People Like Us Live.
As you can tell from the links above, her book is now available. 🙂
In our conversation, we cover the book itself – a pretty tough topic that makes me uncomfortable, and how a course at the Loft Literary Center helped her change and polish the book to help it find a publisher.
In March 2007 (18 months ago), I wrote the following 2 sentences – thinking there might be an interesting short story in behind them. A kind of eco-post-apocalyptic-new-world-esque thing. The contemporary version of re-visiting the grandparents’ abandon, run-down farm in Iowa.
“Future world where ex-urbs are re-claimed by the government and turned back into farmland to feed American citizens and supply the nation’s energy. The story’s from the perspective of someone watching their parents McMansion, on a cul-de-sac, being demo’d to make room for a soy bean field.”
That initial scene stuck with me, longing to find a reason for these changes to be possible and necessary.
You know I have a pet peeve with ‘businesses’ where the metric of success doesn’t start with a $. Perhaps Web 2.0 will end the same way as the ‘first version’ – a huge shake-out wiping places with funny names off the web because they simply weren’t sustainable.
Though, I believe now is different for 1 major reason – $$$. Or more precisely – $. The amount of money, time, energy, effort to maintain a modestly successful (or even not at all successful) project is small. Miniscule. Be-your-own-VC-small.
Add a little ad-revenue atop (not my preferred method, but it works for others I know) that and expenses are covered. Actually transform ‘users’ into customers – priceless. And well positioned for sunnier times. Fun-damentals.