Redis installation Finishing (window platform) +php extended Redis

Source: Internet
Author: User
Tags redis windows vars redis server

Windows Platform Redis Installation

Redis Windows installation files
: Http://code.google.com/p/servicestack/wiki/RedisWindowsDownload#Download_32bit_Cygwin_ Builds_for_windows
My choice of Redis is the latest version of the installation file, see:


after the Redis installation file is unpacked, there are several files. See

Redis-server.exe: Service Program
Redis-check-dump.exe: Local Database check
Redis-check-aof.exe: Update log check
Redis-benchmark.exe: Performance test to simulate the simultaneous sending of M-Sets/gets queries by n clients (similar to the Apache AB tool).

After extracting the Redis installation files to the E:\ root directory, you also need to add a Redis profile redis.conf to the Redis root directory, which is included in the file specific content, but here I still post the contents of the configuration file:

Configuration file

[HTML]View Plaincopy
  1. # Redis Configuration File Example
  2. # By default, Redis does not run as a daemon. Use the ' yes ' if you need it.
  3. # Note that Redis would write a PID file in/var/run/redis.pid when daemonized.
  4. Daemonize No
  5. # when run as a daemon, the Redis write a PID file in/var/run/redis.pid by default.
  6. # can specify a custom PID file location here.
  7. Pidfile/var/run/redis.pid
  8. # Accept connections on the specified port, default is 6379
  9. Port 6379
  10. # If you want your can bind a single interface if the BIND option isn't
  11. # specified all the interfaces would listen for connections.
  12. #
  13. # bind 127.0.0.1
  14. # Close The connection after a client are idle for N seconds (0 to disable)
  15. Timeout 300
  16. # Set Server verbosity to ' debug '
  17. # It can be one of:
  18. # Debug (a lot of information, useful for development/testing)
  19. # notice (moderately verbose, what are want in production probably)
  20. # warning (only very important/critical messages is logged)
  21. LogLevel Debug
  22. # Specify the log file name. Also ' stdout ' can is used to force
  23. # The demon to log in the standard output. Note If you use the standard
  24. # Output for logging but daemonize, logs'll be sent To/dev/null
  25. LogFile stdout
  26. # Set the number of databases. The default database is DB 0, you can select
  27. # A different one on a per-connection basis using SELECT <dbid> where
  28. # dbid is a number between 0 and ' databases '-1
  29. Databases 16
  30. ################################ snapshotting #################################
  31. #
  32. # Save the DB on disk:
  33. #
  34. # Save <seconds> <changes>
  35. #
  36. # would save the DB if both the given number of seconds and the given
  37. # Number of write operations against the DB occurred.
  38. #
  39. # in the example below the behaviour would be is to save:
  40. # After the SEC (min) If at least 1 key changed
  41. # After the SEC (5 min) If at least ten keys changed
  42. # after the SEC if at least 10000 keys changed
  43. Save 900 1
  44. Save 300 10
  45. Save 60 10000
  46. # Compress String objects using LZF when dump. RDB databases?
  47. # for default this ' s set to ' yes ' as it's almost always a win.
  48. # If you want to save some CPU on the saving child set it to ' no ' but
  49. # The DataSet would likely is bigger if you have compressible values or keys.
  50. Rdbcompression Yes
  51. # The filename where to dump the DB
  52. Dbfilename Dump.rdb
  53. # for Default Save/load DB in/from the working directory
  54. # Note that you must specify a directory is not a file name.
  55. Dir./
  56. ################################# REPLICATION #################################
  57. # Master-slave replication. Use slaveof to make a Redis instance a copy of
  58. # another Redis server. Note that the configuration was local to the slave
  59. # So for example it's possible to configure the slave to save the DB with a
  60. # different interval, or to listen to another ports, and so on.
  61. #
  62. # slaveof <masterip> <masterport>
  63. # If The master is password protected (using the "Requirepass" configuration
  64. # directive below) It's possible to tell the slave to authenticate before
  65. # Starting the replication synchronization process, otherwise the master would
  66. # refuse the slave request.
  67. #
  68. # Masterauth <master-password>
  69. ################################## SECURITY ###################################
  70. # Require clients to issue AUTH <PASSWORD> before processing all other
  71. # commands. This might is useful in environments in which don't trust
  72. # Others with access to the host running Redis-server.
  73. #
  74. # This should stay commented out for backward compatibility and because most
  75. # People do not need auth (e.g. they run their own servers).
  76. #
  77. # Requirepass Foobared
  78. ################################### LIMITS ####################################
  79. # Set The max number of connected clients at the same time. By default there
  80. # is no limit, and it's up to the number of file descriptors the Redis process
  81. # is able to open. The special value ' 0 ' means no limts.
  82. # Once The limit is reached Redis would close all the new connections sending
  83. # an error ' max number of clients reached '.
  84. #
  85. # maxclients 128
  86. # Don ' t use more memory than the specified amount of bytes.
  87. # maxmemory <bytes>
  88. AppendOnly No
  89. Appendfsync always
  90. Glueoutputbuf Yes

Extract the Redis_conf.rar from the attachment and place it in the root of the Redis. Here, the Redis installation is complete. Start using the Redis database below.

To start Redis:
Input command: Redis-server.exe redis.conf
After startup as shown:


Start the cmd window to remain open, and the Redis service shuts down when it is closed.
When the service is opened, another window is opened, and the client is set up:
Input command: redis-cli.exe-h 202.117.16.133-p 6379
Enter the following as shown:


Above the IP to write your own OH:

PHP Extended Redis Features

1 First, view the compiled version of PHP v6/v9 in Phpinfo ()

2 Download Extension Address: Https://github.com/nicolasff/phpredis/downloads (note the supported PHP versions)

3 Place the downloaded Php_redis.dll in the PHP extension directory (EXT) and modify the configuration file php.ini

When adding extensions, be sure to

Extension=php_igbinary.dllextension=php_redis.dll This sequence or restart Apache will appear, PHP startup error

4 Restart the service, view Phpinfo (), the following indicates success;

5 Testing with PHP

PHP code

[PHP]View Plaincopy
    1. $redis = new Redis ();
    2. $redis->connect ("192.168.138.2","6379"); //php Client-set IP and port
    3. Store a value
    4. $redis->set ("Say","Hello World");
    5. echo $redis->get ("say"); //should output Hello World
    6. Store multiple values
    7. $array = Array (' first_key ' = 'first_val ',
    8. ' second_key ' = 'second_val ',
    9. ' third_key ' = 'third_val ');
    10. $array _get = Array (' First_key ',' Second_key ',' Third_key ');
    11. $redis->mset ($array);
    12. Var_dump ($redis->mget ($array _get));

Redis installation Finishing (window platform) +php extended Redis

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.