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 OK redis> get favorite_drink "gin"
Once you have a value you can get information from Redis as to its type:
redis> type favorite_drink string
And whether a key exists
redis> exists favorite_drink (integer) 1
I’ll cover more of the excellent features in subsequent posts.
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
require 'rubygems' require 'redis' redis = Redis.new redis.set "foo", "bar"
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:
redis.incr "views" => 1 redis.incr "views" => 2
For non-persistent data like caching it is a really good solution too. You can even use it as the cache in Rack applications.
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Listening to BBC Radio with mpv
The BBC publishes high quality 320 kbps HLS AAC streams that can be used to listen to radio from the command-line using mpv. Here are the URLs and some aliases to start listening quickly.
Vim: So long Pathogen, hello native package loading
Vim 8 added a native way to load third-party packages. This means, for me at least, there is no longer any need to use a third party plugin helper like Pathogen.
Linux and Unix more command tutorial with examples
Tutorial on using more, a UNIX and Linux command for viewing the contents of a file or files one screen at a time. Examples of viewing a file, viewing multiple files, searching using regular expressions and opening the file in a text editor.