Using memcached as a Grails cache

Thanks to Ray Krueger’s hibernate-memached plugin, I have PatriotRoom.com using memached as a 2nd level and query cache.

Why use memached instead of the standard OSCache provider? Two reasons.

One, I’m not overly fond of taking up memory heap for the cache when it can be used for the application itself. This should reduce GC usage as well, and unless I’m missing something the cache should survive application restarts. Giving the amount of cache hits the application gets this would be a big help.

Two, I plan on clustering the application pretty soon, if I can get terracotta working, (that’ll be another post) and having the memached cache means I have a cache that can be used across the two servers.

Yes, I could have done this via clustering OSCache, but this is much simpler.

Ray has some pretty good documentation and the only thing that wasn’t clear was a couple of jars needed (the slf4j ones), but it wasn’t too big of a deal.

5 Total TweetBacks: (Tweet this post)


Don’t miss anything, subscribe!

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

Thanks for the comment Jordan. After taking a quick look, one thing sticks out for me and that is that it is an in-process cache. If I wanted that I would have stuck with OSCache which is the default cache provider for Grails.

I wanted an external cache for the two servers to talk to. I haven’t used, or heard of, sccache, but memcached is a very lightweight and fast cache server, exactly what I wanted. Also, there was a hibernate cache provider for it already, making it just a config change along with a few jars.

Actually, sccache has both in-process and external caching. Each is optional so you can use sccache as an external cache only.

I really should work on a Hibernate wrapper for it. People seem to like that.

Odd – I posted a comment and now it’s gone.

Anyway, sccache has both in-process and external caches (both are optional). I’ve been meaning to add a Hibernate wrapper. If I write it, would you mine giving it a quick test? I’m not a Hibernate user.

Thanks for the feedback! Let me know how things work out for you :)

So far Ray, everything is working great. My app gets about 4 million cache hits in a 24 hour period and I haven’t seen any issues.

Great post! My firm does internet marketing for companies and so a lot of my e-newsletter, blog and seminar content revolve around for promotion. Thanks!!!

[...] this page was mentioned by Murali R (@myparu), webmogul (@webmogul) and others. [...]

This PowerPoint Video converter can easily convert PowerPoint to video in all popular video and audio formats with excellent quality.
iPod Ripper provides an ideal solution for you to manage, rip, copy, backup, restore your iPod/iPhone on personal computer no matter iTunes installed or not
This powerful Capture Streaming Video supports comprehensive video sharing websites, online TV channels, Internet radio station, online movie, live sport, live news report and other streaming video websites
iPhone To Computer Transfer is a powerful converter, mutually trasferring playlists, songs, pictures between iPhone and computer

Great post!

Leave a comment

(required)

(required)