• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase
您的位置:首页 > 数据库 >Redis > 图文详解Windows下使用Redis缓存工具的方法

图文详解Windows下使用Redis缓存工具的方法

作者:daliu_it 字体:[增加 减小] 来源:互联网 时间:2017-05-11

daliu_it通过本文主要向大家介绍了篆刻入门详解图文,周易64卦图文详解,六十四卦图文详解,无线充电原理图文详解,地理图文详解等相关知识,希望本文的分享对您有所帮助

一、简介

redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)和zset(有序集合)。

这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。

Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。

二、下载redis

Redis 官网 :http://redis.io/

下载页面:http://redis.io/download

官方文档:http://redis.io/documentation

Windows 版本下载:https://github.com/dmajkic/redis/downloads

三、环境搭建

1. 放到磁盘里面。

2.根据操作系统 进入相应的目录 ,启动redis服务端 redis-server.exe redis.conf

3.根据操作系统 进入相应的目录 ,启动redis客户端。

4. 测试redis缓存机制。

redis-cli.exe -h 127.0.0.1 -p 6379

set keytest valuestest

get keytest

</div>

5. 效果如下:

6. 测试调换顺序调用的实例。

这个应用可以用在验证码的校验用以及缓存。

第一个号码 18276487300 发送了一个验证码”1234“,然后存到key-values 里面。

第二个号码 18276487301 发送了一个验证码”2345“,然后存到key-values 里面。

但是第二个验证码先进行验证,所以会先通过18276487301 来获取验证码。

这样就防止了一些验证码不知道对应哪个手机号码了。

后面会根据java配置到项目中应用。

四、redis.conf 配置文件
根据操作系统 进入相应的目录 ,会看到一个配置文件redis.conf。
配置文件的原文如下:

# Redis configuration file example

# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /var/run/redis.pid

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379

# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
# bind 127.0.0.1

# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0

# Set server verbosity to 'debug'
# it can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel verbose

# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile stdout

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16

################################ SNAPSHOTTING #################################
#
# Save the DB on disk:
#
#  save <seconds> <changes>
#
#  Will save the 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 will be to save:
#  after 900 sec (15 min) if at least 1 key changed
#  after 300 sec (5 min) if at least 10 keys changed
#  after 60 sec if at least 10000 keys changed
#
#  Note: you can disable saving at all commenting all the "save" lines.

save 900 1
save 300 10
save 60 10000

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes

# The filename where to dump the DB
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 
# Also the Append Only File will be created inside this directory.
# 
# Note that you must specify a directory here, not a file name.
dir ./

################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
#
# slaveof <masterip> <masterport>

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#
# masterauth <master-password>

# When a slave lost the connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#  still reply to client requests, possibly with out of data data, or the
#  data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
#  an error "SYNC with master in progress" to all the kind of commands
#  but to INFO and SLAVEOF.
#
slave-serve-stale-data yes

# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#
# repl-p
  


 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 图文详解Windows下使用Redis缓存工具的方法

相关文章

  • 2017-05-11Windows下Redis的安装使用教程
  • 2017-05-11详解使用Redis SETNX 命令实现分布式锁
  • 2017-05-11详解Redis用链表实现消息队列
  • 2017-05-11详解利用redis + lua解决抢红包高并发的问题
  • 2017-05-11Redis有序集合类型的常用命令小结
  • 2017-05-11Redis 集群搭建和简单使用教程
  • 2017-05-11在Mac OS上安装Vagrant和Docker的教程
  • 2017-05-11Redis实现唯一计数的3种方法分享
  • 2017-05-11Redis中5种数据结构的使用场景介绍
  • 2017-05-11利用Redis实现SQL伸缩的方法简介

文章分类

  • MsSql
  • Mysql
  • oracle
  • MariaDB
  • DB2
  • SQLite
  • PostgreSQL
  • MongoDB
  • Redis
  • Access
  • 数据库其它
  • sybase
  • HBase

最近更新的内容

    • 更好地使用redis
    • Linux中设置Redis开机启动的方法
    • Redis系列(三)--过期策略
    • redis2.8配置文件中文翻译版
    • redis配置文件redis.conf中文版(基于2.4)
    • redis常用命令小结
    • redis+mysql+quartz 一种红包发送功能的实现
    • Redis sort 排序命令详解
    • Redis配置文件详解
    • CentOS系统中Redis数据库的安装配置指南

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有