0% found this document useful (0 votes)
166 views5 pages

11 PDFsam Redis Cookbook

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views5 pages

11 PDFsam Redis Cookbook

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Preface

Introduction
Redis is a data structure server with an in-memory dataset for speed. It is called a data
structure server and not simply a key value store because Redis implements data struc-
tures allowing keys to contain binary safe strings, hashes, sets and sorted sets, as well
as lists. This combination of flexibility and speed makes Redis the ideal tool for many
applications.
Redis first started in early 2009 as a key value store developed by Salvatore Sanfilippo
in order to improve the performance of his own LLOOGG, an analytics product. Redis
grew in popularity after getting support from people and companies in the developer
world and has since been supported by VMware, who hired Salvatore and Pieter
Noordhuis to work full-time on the project.
Today, Redis is used by companies large and small doing both large and small tasks.
Companies like Engine Yard, Github, Craigslist, Disqus, Digg, and Blizzard are part of
the growing list of Redis adopters. An extended list of people working with Redis is
available on the project’s official site at http://redis.io.
There are often several ways to solve problems using Redis. This book, while not a
tutorial on Redis, key value stores, or data structures, gives you recipes for solving
specific problems with Redis that you can then adapt to your own problem set. Many
of these recipes have come up because we’ve used them in our own jobs, solving our
own problems.
Each of these recipes solves a specific problem using Redis, including a quick intro-
duction to the problem, the solution, and a longer discussion with insight into how the
solution works. Redis is, while simple in nature, quite extensive when it comes to func-
tionality to manipulate and store data. This volume will thus not cover every single
command extensively. It will, however, give you the basics on solving specific problems
with it, in hopes that our solutions guide you to your own.

ix

www.it-ebooks.info
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements
such as variable or function names, databases, data types, environment variables,
statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter-
mined by context.

This icon signifies a tip, suggestion, or general note.

This icon indicates a warning or caution.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Redis Cookbook by Tiago Macedo and Fred
Oliveira (O’Reilly). Copyright 2011 Tiago Macedo and Fred Oliveira,
978-1-449-30504-8.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at [email protected].

x | Preface

www.it-ebooks.info
Safari® Books Online
Safari Books Online is an on-demand digital library that lets you easily
search over 7,500 technology and creative reference books and videos to
find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online.
Read books on your cell phone and mobile devices. Access new titles before they are
available for print, and get exclusive access to manuscripts in development and post
feedback for the authors. Copy and paste code samples, organize your favorites, down-
load chapters, bookmark key sections, create notes, print out pages, and benefit from
tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full
digital access to this book and others on similar topics from O’Reilly and other pub-
lishers, sign up for free at http://my.safaribooksonline.com.

How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://www.oreilly.com/catalog/9781449305048
To comment or ask technical questions about this book, send email to:
[email protected]
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Preface | xi

www.it-ebooks.info
Acknowledgements
We thank Pieter Noordhuis for thoroughly reviewing several chapters of our book, our
editor Andy Oram for his work on making us look good, Salvatore Sanfilippo for his
words of encouragement, and our respective companies for the extra free time to write
this book.

xii | Preface

www.it-ebooks.info
CHAPTER 1
An Introduction to Redis

This chapter discusses some of Redis’s basic concepts. We’ll look into when Redis is a
great fit, how to install the server and command-line client on your machines, and
Redis’s data types.

When to use Redis


Problem
Nearly every application has to store data, and often lots of fast-changing data. Until
recently, most applications stored their data using relational database management
systems (RDBMS for short) like Oracle, MySQL, or PostgreSQL. Recently, however, a
new paradigm of data storage has emerged from the need to store schema-less data in
a more effective way—NoSQL. Choosing whether to use SQL or NoSQL is often an
important first step in the design of a successful application.

Solution
There are two important thing to consider when choosing whether to use SQL or
NoSQL to store your data: its nature and your usage pattern. Some data is a great fit
for a relational storage engine, while other data benefits from the schema-free nature
of a NoSQL engine like Redis or its alternatives. If you don’t rely on a particular RDBMS
feature and need the performance or scalability of a NoSQL database, that might in
fact be the ideal choice. So in order to decide whether your data should be stored in a
RDBMS or NoSQL engine, you need to look into a few specific things that will help
you make a decision. Also bear in mind that quite often the ideal solution will be to use
both.

www.it-ebooks.info

You might also like