An overview of Redis
Redis has moved to a 2.0.0 release and is a serious solution for building high-performance, scalable web applications.
A key-value store and more ¶
The 2.0.0 release of Redis is out and offers a super-fast key value store that stores data in-memory. It offers a persistent data store along with support for sets, string values and hashes. Performance wise it is extremely fast and offers replication without too much fuss. As a developer it is a joy to use. On OSX you can install it using homebrew:
brew install redis
and then start the server with
Now you can connect to it with a client and start adding and retrieving data with a client
Here’s a basic example of setting and getting a value
redis> set favorite_drink gin
redis> get favorite_drink
Once you have a value you can get information from Redis as to its type:
redis> type favorite_drink
And whether a key exists
redis> exists favorite_drink
I’ll cover more of the excellent features in subsequent posts.
Using Ruby and Redis ¶
Redis has wrappers for most lanugages including Ruby, Python and PHP. For Ruby you can install the wrapper with
sudo gem install redis
You can then use it in scripts with
redis = Redis.new
redis.set "foo", "bar"
Great for caches and counters ¶
Redis is great for things like counters. Say for example you want to track the number of times a page has been viewed. This is simple with Redis:
For non-persistent data like caching it is a really good solution too. You can even use it as the cache in Rack applications.
Further reading ¶
- Simon Willison’s Redis Tutorial
- Redis: Data Cheeseburgers
- A collection of Redis use cases
- Salvatore Sanfilippo’s blog (the brains behind Redis)
- Redis command reference
Can you help make this article better? You can edit it here and send me a pull request.
Developing subdomain Rails sites locally
Developing local Rails sites with subdomains can be a pain but thanks to a couple of public URLs it can be much simpler.
Linux and Unix tr command tutorial with examples
Tutorial on using tr, a UNIX and Linux command for translating or deleting characters. Examples of converting uppercase to lowercase, deleting specific characters, squeezing repeating patterns and basic finding and replacing.
Drag and drop in HTML5
HTML 5 has the ability to create drag and drop events. This example only works in Firefox 3.5 and Safari 4 but here's a quick tour of how it works.