redis組件,Redis PPT abstract

 2023-10-07 阅读 27 评论 0

摘要:在看一個slideshare的PPT結果沒有下載,只好做下筆記了key-value storeall data lives in memorykeys can expire(or not)fast,light-weightpersistencemultiple databasesQueryable keyspaceSupport for integer countershigher level data structuresatomic operation
在看一個slideshare的PPT結果沒有下載,只好做下筆記了
key-value store
all data lives in memory
keys can expire(or not)
fast,light-weight

persistence
multiple databases
Queryable keyspace
Support for integer counters
higher level data structures
atomic operations
ability to paginate lists without mutating them
master-slave replication
Optional VM feature(new)

ervery write command is logged ASAP
Commands replayed when the server is restarted
Configurable speed/safety(safest by default)

use the select command;0-15 are valid by default,but you can add more in redis.conf
useful for segmemting key namespaces,especially when key queries are needed
MOVE command can be used as a locking primitive

Data Structures
Strings
Strings-as-integers(used by INCR/DECR)
List of Strings
Set of Strings(unique list)
Sorted Set of String(and weights)(ZSET)

Command overview
strings:get,set,increment,decrement
Lists:lrpush,lpop,llen,lrange,ltrim
sets:add,remove,move,length,intersect,union,diff,random
others:save,lastsave can be used to force&verify disk persistence

Atomic Operations
LPUSH/RPUSH:append to head/tail of list
LPOP/RPOP:return & remove first/last element of list
RPOPLPUSH:return & remove the last element of source list and push to the head of the destination list
GETSET:set a key to a new value and return the old value
MGET/MSET:get or set multiple keys to multiple values
SMOVE:move a value from one set to another


Replication
Slave can be used for scalability or redundancy
A master can have multiple slaves.
Slaves are able to accept other slave connections
Redis replication is non-blocking on the master,but blocking on the slave(can't respond to uqeries during initial sync)
Slaves are able to automatically reconnect after an outage

Memcache Replacement
Why? Same as Memcached,but you get more "for free";
Many databases from a single instance of REdis(instead of using namespaces)
Ability to easily backup/transfer state(dump.rdb)
Watch live command on a running instance with the MONITOR command (instead of restarting with -v)
Opportunity to use Redis for other things once you've switched

Work Queue
LPUSH and RPOP were made for this
Resque
Created by Chris Wanstrath.Heavily inspired by DelayedJob.Currently used by GitHub.
Provides:
A Ruby library for creating,querying,and processing jobs
A Rake task for starting a worker which processes jobs
A Sinatra app for monitoring queues,jobs,and workers.

Replace MySQL ORDER BY RAND()
ORDER BY RAND() is very slow(even with a LIMIT clause)
DUplicating the list of IDs as a Redis set is relatively cheap
SRANDMEMBER is fast

Other Interesting Uses of Redis
Nginx HTTP Redis module for cacheing with Redis(ngx_http_redis)
LLOOG.com:Realtime site usage statistics,use alongside Google analytics
EZMobius'Fair Work Scheduler example
Sikwamic:Simple Redis-backend Comet server
RestMQ-A REST/JSON/HTTP based message queue built on Redis
redis-textsearch? A simple full-text search for multiple data stores
















版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/124622.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息