机缘巧合决定了解一下redis。
首先看个关于数据库的图,让想学数据库的同学有一个整体的概念。

好勒,下面说redis。
了解redis
Redis是一个开源,先进的key-value存储,并用于构建高性能,可扩展的Web应用程序的完美解决方案。
一句话概括就是:开源的/基于c语言的/基于内存亦可持久化的高性能的NoSql的键值对数据库。
redis存储结构丰富:字符串类型、散列类型、列表类型、集合类型、有序集合类型。
内存存储与持久化:1秒写入10万键值对、异步写入硬盘
功能丰富:用作数据库、缓存系统、队列
简单稳定:使用命令来读取数据,redis命令比sql语言简单的多
比如我们在post表中查询一个id 为1的学生SQL语句这写:
select title from post where id=1 ;
redis语句只需要一句即可:
HGET post:1 title
了解完毕我们来安装一下,很简单。
首先ubuntu下安装redis
1、打开终端,输入一下命令
$sudo apt-get update $sudo apt-get install redis-server

确认安装。等待安装完成。
2、启动redis。
$redis-server

3、检查Redis是否在工作
$redis-cli

上面的提示127.0.0.1是本机的IP地址,6379为Redis服务器运行的端口。现在输入PING命令,回复pong这说明你已经成功地安装Redis在您的机器上。
Windows下安装redis
1、下载地址:https://github.com/dmajkic/redis/downloads。下载windows版本的redis包。最新的是双版本,32、64位都在一起。
2、下载后解压到自己的某个文件夹。我选择64位的并把让它放在:E:\redis\64bit。在文件夹中可执行的2进制文件共有5个,分别代表如下:

3、打开一个cmd窗口 使用cd命令切换目录到E:\redis\64bit 运行 redis-server.exe redis.conf

4、出现上面那个图就表示启动服务成功了,这时候别启一个cmd窗口,原来的不要关闭,不然就无法访问服务端了。
5、切换到redis目录下运行 redis-cli.exe -h 127.0.0.1 -p 6379 出现下图:

我们可以输入一个简单的测试数据测试。
当我们访问服务端时,我们观察刚刚开启的服务端能看到如下数据。

这时候,就已经完成配置了,现在说下它的的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 Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 # 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 当Redis以守护进程方式运行时,Redis默认会把pid写入/var/run/redis.pid文件,可以通过pidfile指定 # Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. port 6379 指定Redis监听端口,默认端口为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 当 客户端闲置多长时间后关闭连接,如果指定为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 指定日志记录级别,Redis总共支持四个级别:debug、verbose、notice、warning,默认为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 日志记录方式,默认为标准输出,如果配置Redis为守护进程方式运行,而这里又配置为日志记录方式为标准输出,则日志将会发送给/dev/null # To enable logging to the system logger, just set 'syslog-enabled' to yes, # and optionally update the ot