redis安装配置及使用【转】
2011-03-2720:41http://code.google.com/p/redis/
http://redis.io/commands/slaveof
http://redis.io/documentation
http://baike.baidu.com/view/4595959.htm
在线演示:
http://try.redis-db.com/
参考链接:
http://redis.io/
http://github.com/jdp/redisent/tree/master
http://github.com/owlient/phpredis
http://rediska.geometria-lab.net/
python client : https://github.com/andymccurdy/redis-py/downloads
安装:
#yum install sinasrv2-redis
wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz
tar -zxvf redis-2.2.2.tar.gz
cd redis-2.2.2
make
make install
##
cp -p redis-server /usr/local/bin
cp -p redis-benchmark /usr/local/bin
cp -p redis-cli /usr/local/bin
cp -p redis-check-dump /usr/local/bin
cp -p redis-check-aof /usr/local/bin
启动及停止:
nohup redis-server /etc/redis.conf &
redis-cli
/usr/local/sinasrv2/bin/redis-cli -p 7517 shutdown
http://redis.io/topics/data-types-intro
配置:
daemonize yes
port 7613
pidfile /var/run/redis7613.pid
timeout 28800
loglevel verbose
logfile stdout
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dir /data1/redis7613
dbfilename r7613.rdb
appendonly no
appendfsync everysec
vm-enabled no
vm-swap-file /data1/redis7613/r7613.swap
vm-max-memory 0
vm-page-size 32
vm-pages 134217728
vm-max-threads 4
glueoutputbuf yes
hash-max-zipmap-entries 64
hash-max-zipmap-value 512
activerehashing yes
appendonly yes #持久化
82 # SLAVEOF host port
192.168.x.1 # slaveof 192.168.x.1 7113
命令参考:
CommandsClientsDocumentationCommunityDownloadIssues
AllKeysStringsHashesListsSetsSorted SetsPub/SubTransactionsConnectionServer
[*]APPENDkey value Append a value to a key
[*]AUTHpassword Authenticate to the server
[*]BGREWRITEAOFAsynchronously rewrite the append-only file
[*]BGSAVEAsynchronously save the dataset to disk
[*]BLPOPkey timeout Remove and get the first element in a list, or block until one is available
[*]BRPOPkey timeout Remove and get the last element in a list, or block until one is available
[*]BRPOPLPUSHsource destination timeout Pop a value from a list, push it to another list and return it; or block until one is available
[*]CONFIG GETparameter Get the value of a configuration parameter
[*]CONFIG SETparameter value Set a configuration parameter to the given value
[*]CONFIG RESETSTATReset the stats returned by INFO
[*]DBSIZEReturn the number of keys in the selected database
[*]DEBUG OBJECTkey Get debugging information about a key
[*]DEBUG SEGFAULTMake the server crash
[*]DECRkey Decrement the integer value of a key by one
[*]DECRBYkey decrement Decrement the integer value of a key by the given number
[*]DELkey Delete a key
[*]DISCARDDiscard all commands issued after MULTI
[*]ECHOmessage Echo the given string
[*]EXECExecute all commands issued after MULTI
[*]EXISTSkey Determine if a key exists
[*]EXPIREkey seconds Set a key's time to live in seconds
[*]EXPIREATkey timestamp Set the expiration for a key as a UNIX timestamp
[*]FLUSHALLRemove all keys from all databases
[*]FLUSHDBRemove all keys from the current database
[*]GETkey Get the value of a key
[*]GETBITkey offset Returns the bit value at offset in the string value stored at key
[*]GETRANGEkey start end Get a substring of the string stored at a key
[*]GETSETkey value Set the string value of a key and return its old value
[*]HDELkey field Delete a hash field
[*]HEXISTSkey field Determine if a hash field exists
[*]HGETkey field Get the value of a hash field
[*]HGETALLkey Get all the fields and values in a hash
[*]HINCRBYkey field increment Increment the integer value of a hash field by the given number
[*]HKEYSkey Get all the fields in a hash
[*]HLENkey Get the number of fields in a hash
[*]HMGETkey field Get the values of all the given hash fields
[*]HMSETkey field value Set multiple hash fields to multiple values
[*]HSETkey field value Set the string value of a hash field
[*]HSETNXkey field value Set the value of a hash field, only if the field does not exist
[*]HVALSkey Get all the values in a hash
[*]INCRkey Increment the integer value of a key by one
[*]INCRBYkey increment Increment the integer value of a key by the given number
[*]INFOGet information and statistics about the server
[*]KEYSpattern Find all keys matching the given pattern
[*]LASTSAVEGet the UNIX time stamp of the last successful save to disk
[*]LINDEXkey index Get an element from a list by its index
[*]LINSERTkey BEFORE|AFTER pivot value Insert an element before or after another element in a list
[*]LLENkey Get the length of a list
[*]LPOPkey Remove and get the first element in a list
[*]LPUSHkey value Prepend a value to a list
[*]LPUSHXkey value Prepend a value to a list, only if the list exists
[*]LRANGEkey start stop Get a range of elements from a list
[*]LREMkey count value Remove elements from a list
[*]LSETkey index value Set the value of an element in a list by its index
[*]LTRIMkey start stop Trim a list to the specified range
[*]MGETkey Get the values of all the given keys
[*]MONITORListen for all requests received by the server in real time
[*]MOVEkey db Move a key to another database
[*]MSETkey value Set multiple keys to multiple values
[*]MSETNXkey value Set multiple keys to multiple values, only if none of the keys exist
[*]MULTIMark the start of a transaction block
[*]PERSISTkey Remove the expiration from a key
[*]PINGPing the server
[*]PSUBSCRIBEpattern Listen for messages published to channels matching the given patterns
[*]PUBLISHchannel message Post a message to a channel
[*]PUNSUBSCRIBE] Stop listening for messages posted to channels matching the given patterns
[*]QUITClose the connection
[*]RANDOMKEYReturn a random key from the keyspace
[*]RENAMEkey newkey Rename a key
[*]RENAMENXkey newkey Rename a key, only if the new key does not exist
[*]RPOPkey Remove and get the last element in a list
[*]RPOPLPUSHsource destination Remove the last element in a list, append it to another list and return it
[*]RPUSHkey value Append a value to a list
[*]RPUSHXkey value Append a value to a list, only if the list exists
[*]SADDkey member Add a member to a set
[*]SAVESynchronously save the dataset to disk
[*]SCARDkey Get the number of members in a set
[*]SDIFFkey Subtract multiple sets
[*]SDIFFSTOREdestination key Subtract multiple sets and store the resulting set in a key
[*]SELECTindex Change the selected database for the current connection
[*]SETkey value Set the string value of a key
[*]SETBITkey offset value Sets or clears the bit at offset in the string value stored at key
[*]SETEXkey seconds value Set the value and expiration of a key
[*]SETNXkey value Set the value of a key, only if the key does not exist
[*]SETRANGEkey offset value Overwrite part of a string at key starting at the specified offset
[*]SHUTDOWNSynchronously save the dataset to disk and then shut down the server
[*]SINTERkey Intersect multiple sets
[*]SINTERSTOREdestination key Intersect multiple sets and store the resulting set in a key
[*]SISMEMBERkey member Determine if a given value is a member of a set
[*]SLAVEOFhost port Make the server a slave of another instance, or promote it as master
[*]SMEMBERSkey Get all the members in a set
[*]SMOVEsource destination member Move a member from one set to another
[*]SORTkey ] Sort the elements in a list, set or sorted set
[*]SPOPkey Remove and return a random member from a set
[*]SRANDMEMBERkey Get a random member from a set
[*]SREMkey member Remove a member from a set
[*]STRLENkey Get the length of the value stored in a key
[*]SUBSCRIBEchannel Listen for messages published to the given channels
[*]SUNIONkey Add multiple sets
[*]SUNIONSTOREdestination key Add multiple sets and store the resulting set in a key
[*]SYNCInternal command used for replication
[*]TTLkey Get the time to live for a key
[*]TYPEkey Determine the type stored at key
[*]UNSUBSCRIBE] Stop listening for messages posted to the given channels
[*]UNWATCHForget about all watched keys
[*]WATCHkey Watch the given keys to determine execution of the MULTI/EXEC block
[*]ZADDkey score member Add a member to a sorted set, or update its score if it already exists
[*]ZCARDkey Get the number of members in a sorted set
[*]ZCOUNTkey min max Count the members in a sorted set with scores within the given values
[*]ZINCRBYkey increment member Increment the score of a member in a sorted set
[*]ZINTERSTOREdestination numkeys key ] Intersect multiple sorted sets and store the resulting sorted set in a new key
[*]ZRANGEkey start stop Return a range of members in a sorted set, by index
[*]ZRANGEBYSCOREkey min max Return a range of members in a sorted set, by score
[*]ZRANKkey member Determine the index of a member in a sorted set
[*]ZREMkey member Remove a member from a sorted set
[*]ZREMRANGEBYRANKkey start stop Remove all members in a sorted set within the given indexes
[*]ZREMRANGEBYSCOREkey min max Remove all members in a sorted set within the given scores
[*]ZREVRANGEkey start stop Return a range of members in a sorted set, by index, with scores ordered from high to low
[*]ZREVRANGEBYSCOREkey max min Return a range of members in a sorted set, by score, with scores ordered from high to low
[*]ZREVRANKkey member Determine the index of a member in a sorted set, with scores ordered from high to low
[*]ZSCOREkey member Get the score associated with the given member in a sorted set
[*]ZUNIONSTOREdestination numkeys key ] Add multiple sorted sets and store the resulting sorted set in a new key
This website is open source softwaredeveloped by Citrusbyte.
页:
[1]