5 usage Scenarios for Redis
Redis is a powerful storage of memory data structures, including databases, caches, and message brokers for a variety of purposes. Most people often think of it as just a simple key-value store, but in fact it has more power. I'll summarize some real examples of what Redis can do.
1. Full P
EVAL script Numkeys key [key ...] arg [arg ...]
Starting with the Redis 2.6.0 release, the LUA script can be evaluated using the EVAL command with the built-in LUA interpreter.The script parameter is a LUA 5.1 script that runs in the Redis server context, which does not have to (and should not) be defined as a LUA function.The Numkeys parameter is used to specify the number of key name parameters.Key Name
.
What about the memcached mentioned before? In fact, it is the same configuration:
CACHES = { ' default ': { ' backend ': ' Django.core.cache.backends.memcached.MemcachedCache ', ' location ': ' 127.0.0.1:11211 ', }}
Of course the usage is the same as the example above me. In fact, for a cache server such as Redis, configuration is very simple, and the specific use is not difficult, the
primary server. At the same time slave is read-only mode, which avoids slave cached data being modified by mistake.In actual production, the master-slave architecture installs the appropriate Redis services on several different servers. For testing convenience, the configuration of the master and slave backup on my side is tested on my Windows native computer.1. Install two Redis instances, master and slav
PHP Redis Extensions installation, configuration, usage summary
System is the lamp environment (centos6.7+apache2.2+mysql5.7+php5.3), the default
Software download to the/USR/LOCAL/SRC directory Redis installed under the/app/local/redis directory
#wget http://download.redis.io/releases/
Zadd key Score member [[Score member] [SCORE member] ...]
Adds one or more member elements and their score values to the ordered set key.If a member is already a member of an ordered set, update the member score value and ensure that the member is in the correct position by re-inserting the member element.The score value can be an integer value or a double-precision floating-point number.If the key does not exist, an empty ordered set is created and the Zadd operation is performed.An error is r
(jedispool
Manager.class) {if (manager = = null) {manager = new Jedispoolmanager ();
}}} return manager;
} public Jedis GetResource () {return pool.getresource ();
} public void Destroy () {//when closing your Application:pool.destroy ();
} public void Close () {pool.close ();
}
}
Redis.properties as follows:
# Redis Server IP and Port
redis.server=172.18.19.208:6379
# Redis
OverviewRedis-sentinel is a highly available (HA) solution that is officially recommended by Redis, and if Master is down, the Redis itself (including many of its clients) does not implement automatic primary and standby switching when using Redis for master-slave high-availability scenarios. The Redis-sentinel itself
A Redis usage bug record (EXEC)
In one project, the blogger used the Redis class in the tool class because the Redis did not encapsulate the pipeline pipeline and EXEC commands, so pen a __call.
The code is as follows (where $this->_connect () returns a Redis instance).
Af
I went out for an interview yesterday and was asked by the interviewer how to view the memory footprint of the Redis. I've never had a problem with this, I went back to the company, checked it out, and recorded this problem in this. How to view the memory usage of Redis.
We can use the REDIS-CLI connection on the
-Bash: make: command not found
Centos execution
The Code is as follows:
Copy code
Yum install make
If you cannot connect to wget
The Code is as follows:
Copy code
-Bash: wget: command not found
Centos execution
The Code is as follows:
Copy code
Yum install wget
Start the server
The Code is as follows:
Copy code
$ Src/redis
get the values of the fields in the hash table, where key represents the Hashtable key, and field represents the domain of the Hashtable:Redis 127.0.0.1:6379> sort uid by user_info_*->level1) "2"2) "3"3) "4"4) "1"Redis 127.0.0.1:6379> sort uid by User_info_*->level get User_info_*->name1) "Jack"2) "Peter"3) "Mary"4) "Admin"11. Save sorting resultsBy default, the sort operation simply returns the sort result without any save operation.You can save the
have been using Redis, but they have not been manually installed, today in their own Mac fencing try, record easy to follow their own installation and deployment of servers;At present, the company is using 2.8 version point Redis; I'm personally installing 2.6.16.
Step1. Download
Redis 2.6.16 Version of: http://download.redis.io/releases/
and memory usage issues with Redis. To fix this issue run the command ' echo never >/sys/kernel/mm/transparent_hugepage/enabled ' as root, and add it to you R/etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.[32555] 12:06:37.804 # warning:the TCP Backlog setting of 511 cannot be enforced BECAUSE/PROC/SYS/N
hdel key field [field ...]
Deletes one or more specified domains in the hash table key, and the nonexistent fields are ignored.In versions below Redis2.4, Hdel can delete only a single domain at a time, and if you need to delete multiple domains in an atomic time, include the command in the Multi/exec block.Available versions:2.0.0+Complexity of Time:O (n), n is the number of fields to be deleted.return value:The number of domains successfully removed, excluding ignored domains.Test data
Redis server performance with host 127.0.0.1 Port 6379Benchmark Tool Test Information:Test command:Redis-benchmark-n 100000-C 60Send 100,000 requests to the Redis server with 60 concurrent clients per requestResults (partial):====== SET ======Writing a test to a collection100000 requests completed in 2.38 seconds100,000 requests completed in 2.38 secondsParallel clients60 Concurrent Clients per request3 by
This article mainly introduces the Redis installation and use method, combined with the example form analysis of Redis database download, installation, startup, setup and related use of operational considerations, the need for friends can refer to
This article summarizes how Redis is installed and used. Share to everyone for your reference, as follows:
1. Downlo
The example in this article describes the Go language operation Redis usage. Share to everyone for your reference. Specifically as follows:
Copy Code code as follows:
Package Main
Import (
"FMT"
"Log"
"Redis"
)
Func Main () {
Defaultspec () Create a connection specification
Spec: = Redis. Defaultsp
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.