Redis Installation and use

Source: Internet
Author: User
Tags app service

Redis is a server for memory-storage data structures, typically using Redis as a cache server, and Redis supports not only simple keyvalue string structures, but also map, List, set data structures, and high read performance. In a distributed environment, the Redis storage session is also used to achieve the purpose of sharing the session. Redis data is stored in memory, and as the amount of data grows, so does the memory burden, which typically requires a separate server in the production environment to support and avoid Redis impacting web App service performance. #下载Redis, unzip, compile and install
1 wget http://download.redis.io/releases/redis-3.0.7.tar.gz2 tar-xvzf redis-3.0.7. tar.gz3 cd redis-3.0.74make5
#创建运行命令路径, and configuration files
Mkdir/usr/local/rediscp-rf./src/redis-cli./src/redis-server./redis.conf/usr/local/redis/cd/usr/local/redis/
#编辑redis. conf configuration file
Daemonize Yespidfile/var/run/redis.pidport 6379
#设置开机自启动命令#新建编辑/etc/init.d/redis
redisport=6379exec=/usr/local/redis/redis-servercliexec=/usr/local/redis/redis-clipidfile=/var/run/ redis.pidconf= "/usr/local/redis/redis.conf" case "$" in    start)        if [-f $PIDFILE] then            echo "$PIDFILE exists, process is already running or crashed "        else            echo" Starting Redis server ... "            $EXEC $CONF        fi        ;;     stop)        if [!-F $PIDFILE] then            Echo ' $PIDFILE does not exist, process was not running '        else            pid=$ (cat $PIDFI LE)            echo "Stopping ..." $CLIEXEC-            p $REDISPORT shutdown while            [-x/proc/${pid}] do                echo " Waiting for Redis to shutdown ... "                sleep 1 done            echo" Redis stopped "        fi        ;;    *)        echo "Please use Start or stop as first argument"        ;; Esac
# Join the system service
chmod +x/etc/init.d/redischkconfig--add redischkconfig Redis on
#启动服务Service Redis Start # Redis Query command
/USR/LOCAL/REDIS/REDIS-CLI flushall/usr/local/redis/redis-cli-n 0 Keys ' * '/usr/local/redis/redis-cli-n 0 dbsize/usr/ Local/redis/redis-cli-n 0 flushdb/usr/local/redis/redis-cli-n 0 Keys ' * ' | Wc-l
#windows扩展下载HTTP://WINDOWS.PHP.NET/DOWNLOADS/PECL/SNAPS/REDIS/2.2.5/Unzip the Redis expansion pack and PHP_ Redis.dll Copy to PHP installation directory extends and configure php.ini append [redis]extension = php_redis.dll; Restart Apache server, use Echo phpinfo (), install extension successfully. #PHP中使用Redis存储读取数据
1 $cache New Redis; 2 $cache->connect (' 192.168.56.102 ', 6379); 3 $cache->set ("test", "Hello Redis"); 4 Var_dump ($cache->get ("test"));
#如果连接不上Note that the IP address of the redis.conf binding.

Redis Installation and use

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.