wget with no output
redis: getting started
“Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.” (source)
Also, redis commands are atomic operations.
Installation
# Check out the home page for the latest version! $ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz $ tar xvzf redis-2.6.14.tar.gz $ cd redis-2.6.14 $ make $ sudo make install
Then start the redis server:
$ redis-server
The server, by default, will listen on localhost:6379
.
Graphical interface
Do you like phpMyAdmin? Well, there is something similar to redis too called Redis Commander. Check out the project’s home page for installation instructions.
Redis Commander is written in node.js. For installing node.js, refer to this post: Installing Node.js and NPM on Ubuntu/Debian.
Python binding
At this point you might ask the natural question: “OK, but how can I use it from Python?”. You need the following client:
sudo pip install redis -U
Let’s test it:
>>> import redis >>> r = redis.Redis() # default: localhost, port 6379 >>> r.set("name", "jabba") True >>> r.get("name") 'jabba'
Let’s see another example with a list:
>>> import redis >>> r = redis.Redis() # the list is called "test" # rpush: right push, i.e. put an element on its right side (tail) >>> r.rpush("test", 24) 1L >>> r.rpush("test", 67) 2L >>> r.rpush("test", 9) 3L # list all the elements (-1 is the index of the last element) >>> r.lrange("test", 0, -1) ['24', '67', '9'] # number of elements >>> r.llen("test") 3 # delete the list if you don't need it anymore >>> r.delete("test") 1
Save the database
It is possible to save the database to disk. When you restart the server, it can restore the database from disk.
The database will be saved to the directory where you started redis! For instance, you started redis from your HOME
directory. In a Python script you called “r.save()
“, which creates a snapshot of the database and dumps it to “~/dump.rdb
“. When you start the server, it checks for this dump file in the current directory. If “./dump.rdb
” is found, it will be loaded.
If you run redis-server
in a terminal, check out its log. It will indicate if it found and loaded a database upon startup.
Links
- Redis HQ
- Redis commands (@Redis HQ)
- The Little Redis Book
- Getting Started: Redis and Python
- redis-py (Python client)
- How To Install and Use Redis @DigitalOcean (explains how to start redis automatically after boot)
Mongoose web server
It’s very easy to start a Python web server on localhost.
If you want something more serious but still lightweight, check out the Mongoose web server.
Fetch and compile:
wget https://mongoose.googlecode.com/files/mongoose-3.8.tgz tar xvzf mongoose-3.8.tgz cd mongoose make linux
The user manual is here.
Scala tutorials
Wanna learn Scala? Visit http://scalatutorials.com/.
[ found here ]
PrimCom: manage and access your personal knowledge base easily
I am proud to announce my newest project called PrimCom, which is a personal knowledge base manager, primarily made for programmers. I made a detailed description of the project here, I don’t want to repeat the whole text here.
Links
Update (20130808)
PrimCom was included in Python Weekly #99. Great!
Related work
- cheat (It was designed to help remind *nix system administrators of options for commands that they use frequently, but not frequently enough to remember.)
Log in to comment
Dear Readers,
The spam filter on wordpress.com has not been very efficient recently. Too many spam messages get the “pending” status that I need to review manually. I can’t imagine why they aren’t flagged automatically as spam…
I got tired of these spam messages, thus from now on you must be logged in if you want to leave a comment. Thank you for your understanding. I hope you will still leave comments, I love receiving feedbacks.
Best wishes,
Jabba Laci
You must be logged in to post a comment.