This article mainly introduces the cache technology of a Redis installation and use for your reference, the specific contents are as follows
First, download Redis for Windows
Searching the network for Redis fow windows, you can download Redis's compressed package. Unpack the package.
You will find that there are 32-bit and 64-bit different versions of the package, as needed, using the corresponding compression package.
Second, decompression
I am using a Redisbin_x64.zip compressed package to extract it into a Redis folder.
After decompression, you will find that the content has only some. exe files. Here, Redis is half done.
Third, the configuration
Under Redis, create a new folder for Conf and a redis.conf text file. Copy the contents to the configuration file.
# Redis configuration File Example # By default Redis does not run as a daemon.
Use ' yes ' if you need it.
# that Redis'll write a PID file in/var/run/redis.pid when daemonized.
# whether to run later in the form of a process, the default is no Daemonize no # when run as a daemon, Redis write a PID file in/var/run/redis.pid by default.
# can specify a custom PID file location here. # If you specify a later form execution, you need to specify a PID file Pidfile/var/run/redis.pid # Accept connections on the specified port, and the default is 6379 #监听 Port number Port 6379 # If you want can bind a single interface, If the bind option are NOT # specified all the interfaces
'll listen for connections. # BIND host IP # bind 127.0.0.1 # Close the connection after a client was idle for N seconds (0 to disable) # Client idle timeout, set to 0 , there is no timeout. After idle time, the client's connection is turned off timeout # Set server verbosity to ' debug ' # It can be one of: # Debug (a lot of information, Useful for development/testing) # Notice (moderately verbose, what to want in production probably) # warning (Only very important/critical messages are logged) # logging level loglevel Debug # Specify the log file name. Also ' stdout ' can be used to force # The demon to log on the standard output. Note this if you use standard # Output for logging but daemonize, logs'll be sent To/dev/null # logging way logfile Stdou t # Set the number of databases.
The default database is DB 0, your can select # a different one on a per-connection basis using select <dbid> where # dbid is a number between 0 and ' databases '-1 # available databases databases ################################ snapshotting ################################# # Save the DB on disk: # Save <seconds> <changes> # 'll save th
E DB If both the given number of seconds and the given # Number of write operations against the DB occurred. # in the example below the behaviour is to save: # after 900 sec (min) If at least 1 key changed # after 300 SEC (5 min) If at least keys changed # after 60SEC if at least 10000 keys changed save 900 1 save a 10000 # Compress string objects using LZF when Dum
P. RDB databases?
# for default so ' s set to ' yes ' as it ' s almost always a win. # If you are want to save some CPU into the saving child set it to ' no ' but # the dataset would likely be bigger If you have COM
Pressible values or keys. # when storing to the local database, do you want to compress the data rdbcompression Yes # The filename where to dump the DB #本地数据名称 dbfilename Dump.rdb # for Def
Ault Save/load DB In/from The Working directory # This is the must specify a directory not a file name. # Local Database store path dir./################################# REPLICATION ################################# # Master-slave R Eplication. Use slaveof to make a Redis instance a copy of # another Redis server. The "configuration is" the "is" slave # so for example it's possible to configure the slave to save the DB W
ith a # different interval, or to listen to another port, and. # Set up the main service when the service is from serviceIP address and Port number # # slaveof <masterip> <masterport> # If The master is password protected (using the ' Requirepa SS "Configuration # directive below" It is possible to tell the slave to authenticate before # starting
Synchronization process, otherwise the master would # refuse the slave request. # When the service is from the service, set the connection password for the primary service # # Masterauth <master-password> ################################## Security ########### ######################## # Require clients to issue AUTH <PASSWORD> before all other processing.
This might is useful in environments into which you don't trust # others and access to the host running Redis-server. # This should stay commented out for backward compatibility and because most # people does not need auth (e.g. they run
their own servers). # Connect Password # # Requirepass foobared ################################### LIMITS #################################### # Set the max number of connected clients at the SAME time. By default there # is no limit, and it's up to the number of file descriptors the Redis process # was able to open.
The special value ' 0 ' means no limts.
# Once The limit is reached Redis'll close all the new connections sending # A error ' max number of clients reached '.
# Maximum client connections, default not set # # maxclients 128 # Don ' t use more memory than the specified amount of bytes. # When the memory limit is reached Redis'll try to remove keys with a # EXPIRE set.
It'll try to start freeing the keys that are going to expire # into little time and preserve the keys with a longer time to live.
# Redis would also try to remove objects from free lists if possible. # If All this fails, Redis'll start to reply with errors to commands # That'll use more memory, like SET, Lpush, a
nd so on, and would continue # to reply to most read-only commands like. # # warning:maxmemory can be a good idea mainly if your want to use Redis as a # ' state ' server or cache, not as a real Db. wheN Redis is used as a real # database The memory usage would grow over the weeks, it would be obvious if # it is going to u Se too much memory in the long run, and you'll have the time # to upgrade. With MaxMemory after the limit are reached you'll start to get # Errors for write operations, and this may even leads to DB
Inconsistency.
# Set the maximum memory, the maximum memory settings, the Redis line to try to clear the expired or expiring key, when this method is processed, the maximum memory settings, will not be in the write operation. # # MaxMemory <bytes> ############################## APPEND only MODE ############################### # by de Fault Redis asynchronously dumps the dataset on disk. If you can live # and the idea that the latest records'll be lost if something like a crash # happens this is the pre Ferred way to run Redis. If instead you care a lot # about your data and don ' t want to so a single record can get lost you should # enable the Append only mode:when This mode is enabled Redis'll append # Every write operation received in the file Appendonly.log . This file would # is READ on the "Startup in order" to rebuild the full dataset in memory. # # That's you can have both the async dumps and the append ' only file if ' like ' (you have to comment the "save" s
Tatements above to disable the dumps). # still if append only mode is enabled Redis'll load the data from the # log file at startup ignoring the Dump.rdb file
. # The name of the ' Append Only ' is ' appendonly.log ' # Important:check the bgrewriteaof to Check how to rewrite
The Append # log file in background when it gets too.
# set the Redis server after each operation completes, whether to update log operations and, if turned off, may result in loss of data over time during a power outage, # because the Redis itself synchronizes data files according to the save conditions above, some data is stored in memory for a period of time. AppendOnly No # Update log file name # appendfilename Appendonly.aof # The Fsync () call tells the operating System to actually W Rite data on disk # instead ' to ' wait for more data in the output buffer.
Some OS would really flush # data on disk, Some the other OS would just try to do it ASAP. # # Redis supports three different modes: # No:don ' t Fsync, just Let's the OS flush the data when it wants.
Faster. # Always:fsync after every write to the append only log.
Slow, safest. # Everysec:fsync only if one second passed since the last fsync.
Compromise. # The default is ' always ', that ' s the safer of the options. It ' s up to # Understand if I can relax this to "everysec", that'll fsync every second # or to "No", that'll l ET the operating system flush the output buffer when # It want, for better performances (but if you can live with the IDE
A of # Some data loss consider the default persistence mode that ' s snapshotting). # Update log criteria with three optional values: Appendfsync always # appendfsync everysec # Appendfsync no ############################### Advanc ED CONFIG ############################### # Glue Small output buffers together in order to send small replies in a # s Ingle TCP Packet. Uses a bit more CPUs but most of the times it's a win # in terms of number of queries per second.
Use ' yes ' if unsure. #glueoutputbuf Yes # Use object sharing. Can save a lot of memory if you have many common # string in your dataset, but performs-lookups against the shared object S # Pool So it uses the CPU and can be a bit slower.
Usually it ' s a good # idea. # When object sharing are enabled (Shareobjects Yes) you can use # Shareobjectspoolsize to control the size of the pool Used in order to try # Object sharing.
A bigger pool size would lead to better sharing capabilities. # In general you want this value to being at least's the number of # Very common strings you have in your datase T. # # Warning:object sharing is experimental, don ' t enable this feature # in production before of Redis 1.0-stable.
Still try this feature into # Your development environment so we can test it better.
# shareobjects No # shareobjectspoolsize 1024 # Whether virtual memory is used #vm-enabled no; # Virtual memory file path, cannot multiple Redis share # Vm-swap-file/tmp/redis.swap # store all data greater than vm-max-memory in virtual memory.
Regardless of the size of the Vm-max-memory value, all index data is memory data.# If you set the Vm-max-memory to 0, all the data is stored on disk.
# Vm-max-memory 0
Four, start Redis server
Use the command to start the Redis server.
Redis-server.exe conf/redis.conf
After the startup is successful, you will see the following tips:
V. Connect REDIS Server
Use the Redis command to connect to the server.
Redis-cli.exe-h localhost-p 6379
After the connection succeeds, the following is prompted:
This time, you will be able to use Redis instructions to manipulate the data. Other instructions, please check the details online.
The above is the entire content of this article, I hope to help you learn.