Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Foreword

Preface

Acknowledgments

About this Book

About the Cover Illustration

1. Getting started

Chapter 1. Getting to know Redis

1.1. What is Redis?

1.1.1. Redis compared to other databases and software

1.1.2. Other features

1.1.3. Why Redis?

1.2. What Redis data structures look like

1.2.1. Strings in Redis

1.2.2. Lists in Redis

1.2.3. Sets in Redis

1.2.4. Hashes in Redis

1.2.5. Sorted sets in Redis

1.3. Hello Redis

1.3.1. Voting on articles

1.3.2. Posting and fetching articles

1.3.3. Grouping articles

1.4. Getting help

1.5. Summary

Chapter 2. Anatomy of a Redis web application

2.1. Login and cookie caching

2.2. Shopping carts in Redis

2.3. Web page caching

2.4. Database row caching

2.5. Web page analytics

2.6. Summary

2. Core concepts

Chapter 3. Commands in Redis

3.1. Strings

3.2. Lists

3.3. Sets

3.4. Hashes

3.5. Sorted sets

3.6. Publish/subscribe

3.7. Other commands

3.7.1. Sorting

3.7.2. Basic Redis transactions

3.7.3. Expiring keys

3.8. Summary

Chapter 4. Keeping data safe and ensuring performance

4.1. Persistence options

4.1.1. Persisting to disk with snapshots

4.1.2. Append-only file persistence

4.1.3. Rewriting/compacting append-only files

4.2. Replication

4.2.1. Configuring Redis for replication

4.2.2. Redis replication startup process

4.2.3. Master/slave chains

4.2.4. Verifying disk writes

4.3. Handling system failures

4.3.1. Verifying snapshots and append-only files

4.3.2. Replacing a failed master

4.4. Redis transactions

4.4.1. Defining users and their inventory

4.4.2. Listing items in the marketplace

4.4.3. Purchasing items

4.5. Non-transactional pipelines

4.6. Performance considerations

4.7. Summary

Chapter 5. Using Redis for application support

5.1. Logging to Redis

5.1.1. Recent logs

5.1.2. Common logs

5.2. Counters and statistics

5.2.1. Storing counters in Redis

5.2.2. Storing statistics in Redis

5.2.3. Simplifying our statistics recording and discovery

5.3. IP-to-city and -country lookup

5.3.1. Loading the location tables

5.3.2. Looking up cities

5.4. Service discovery and configuration

5.4.1. Using Redis to store configuration information

5.4.2. One Redis server per application component

5.4.3. Automatic Redis connection management

5.5. Summary

Chapter 6. Application components in Redis

6.1. Autocomplete

6.1.1. Autocomplete for recent contacts

6.1.2. Address book autocomplete

6.2. Distributed locking

6.2.1. Why locks are important

6.2.2. Simple locks

6.2.3. Building a lock in Redis

6.2.4. Fine-grained locking

6.2.5. Locks with timeouts

6.3. Counting semaphores

6.3.1. Building a basic counting semaphore

6.3.2. Fair semaphores

6.3.3. Refreshing semaphores

6.3.4. Preventing race conditions

6.4. Task queues

6.4.1. First-in, first-out queues

6.4.2. Delayed tasks

6.5. Pull messaging

6.5.1. Single-recipient publish/subscribe replacement

6.5.2. Multiple-recipient publish/subscribe replacement

6.6. Distributing files with Redis

6.6.1. Aggregating users by location

6.6.2. Sending files

6.6.3. Receiving files

6.6.4. Processing files

6.7. Summary

Chapter 7. Search-based applications

7.1. Searching in Redis

7.1.1. Basic search theory

7.1.2. Sorting search results

7.2. Sorted indexes

7.2.1. Sorting search results with ZSETs

7.2.2. Non-numeric sorting with ZSETs

7.3. Ad targeting

7.3.1. What’s an ad server?

7.3.2. Indexing ads

7.3.3. Targeting ads

7.3.4. Learning from user behavior

7.4. Job search

7.4.1. Approaching the problem one job at a time

7.4.2. Approaching the problem like search

7.5. Summary

Chapter 8. Building a simple social network

8.1. Users and statuses

8.1.1. User information

8.1.2. Status messages

8.2. Home timeline

8.3. Followers/following lists

8.4. Posting or deleting a status update

8.5. Streaming API

8.5.1. Data to be streamed

8.5.2. Serving the data

8.5.3. Filtering streamed messages

8.6. Summary

3. Next steps

Chapter 9. Reducing memory use

9.1. Short structures

9.1.1. The ziplist representation

9.1.2. The intset encoding for SETs

9.1.3. Performance issues for long ziplists and intsets

9.2. Sharded structures

9.2.1. HASHes

9.2.2. SETs

9.3. Packing bits and bytes

9.3.1. What location information should we store?

9.3.2. Storing packed data

9.3.3. Calculating aggregates over sharded STRINGs

9.4. Summary

Chapter 10. Scaling Redis

10.1. Scaling reads

10.2. Scaling writes and memory capacity

10.2.1. Handling shard configuration

10.2.2. Creating a server-sharded connection decorator

10.3. Scaling complex queries

10.3.1. Scaling search query volume

10.3.2. Scaling search index size

10.3.3. Scaling a social network

10.4. Summary

Chapter 11. Scripting Redis with Lua

11.1. Adding functionality without writing C

11.1.1. Loading Lua scripts into Redis

11.1.2. Creating a new status message

11.2. Rewriting locks and semaphores with Lua

11.2.1. Why locks in Lua?

11.2.2. Rewriting our lock

11.2.3. Counting semaphores in Lua

11.3. Doing away with WATCH/MULTI/EXEC

11.3.1. Revisiting group autocomplete

11.3.2. Improving the marketplace, again

11.4. Sharding LISTs with Lua

11.4.1. Structuring a sharded LIST

11.4.2. Pushing items onto the sharded LIST

11.4.3. Popping items from the sharded LIST

11.4.4. Performing blocking pops from the sharded LIST

11.5. Summary

Appendix A. Quick and dirty setup

A.1. Installation on Debian or Ubuntu Linux

A.2. Installing on OS X

A.3. Installing on Windows

A.3.1. Drawbacks of Redis on Windows

A.3.2. Installing Redis on Windows

A.3.3. Installing Python on Windows

A.4. Hello Redis

Appendix B. Other resources and references

B.1. Forums for help

B.2. Introductory topics

B.3. Queues and other libraries

B.4. Data visualization and recording

B.5. Data sources

B.6. Redis experiences and articles

Index

List of Figures

List of Tables

List of Listings

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.11