Redis 1:简介

导读:在今日开讲的项目中,用到了redis数据库。老听大家在说,我都不知道是个啥玩意儿。然后这两天在准备知识分享的事儿,我先大概了解了解,然后讲的时候,能有点共鸣。所以,本篇博客,是在自己跟读完MVA的一集Redis视频,自己浅显总结的一个基本内容。在下一篇博客,会介绍一下其基本使用。


一、概念

Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

简单说来:它就是一种数据库,支持5种数据结构:strings,hashes,lists,sets,sorted sets。

PS:从SQL和NOSQL的角度来说:Redis是一种非关系型的数据库。


二、特点

易于维护和配置:它的数据是以简单的文件形式保存在磁盘中,它可以通过复制的方式实现备份。

以配置文件进行驱动;主从复制。

Redis拥有两种不同形式的持久化方法,它们都可以用小而紧凑的格式将存储在内存中的数据写入硬盘:第一种持久化方法为时间点转储(point-in-time dump),转储操作既可以在“指定时间段内有指定数量的写操作执行”这一条件被满足时执行,又可以通过调用两条转储到硬盘(dump-to-disk)命令中的任何一条来执行;第二种持久化方法将所有修改了数据库的命令都写入一个只追加(append-only)文件里面,用户可以根据数据的重要程度,将只追加写入设置为从不同步(sync)、每秒同步一次或者每写入一个命令就同步一次


三、和其他数据库或service的对比

名称

类型

数据存储选项

查询类型

附加功能

Redis

使用内存存储(in-memory)的非关系数据库

字符串、列表、集合、散列表、有序集合

每种数据类型都有自己的专属命令,另外还有批量操作(bulk operation)和不完全(partial)的事务支持

发布与订阅,主从复制(master/slave replication),持久化,脚本(存储过程,stored procedu

MemCache

使用内存存储的键值缓存

键值之间的映射

创建命令、读取命令、更新命令、删除命令以及其他几个命令

为提升性能而设的多线程服务器

MongoDB

使用硬盘存储(on-disk)的非关系文档存储

每个数据库可以包含多个表,每个表可以包含多个无schema(schema-less)的BSON文档

创建命令、读取命令、更新命令、删除命令、条件查询命令等

支持map-reduce操作,主从复制,分片,空间索引(spatial index)

 在这里,我简单说明一下Redis和MemCache的使用经历,Mongo还在学,还没有用过,就不瞎说了。

the difference between Redis and MemCache:

 You should not care too much about performances. Redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. Also memcached is faster with big values in the order of 100k. Redis recently improved a lot about big values (unstable branch) but still memcached is faster in this use case. The point here is: nor one or the other will likely going to be your bottleneck for the query-per-second they can deliver.

    You should care about memory usage. For simple key-value pairs memcached is more memory efficient. If you use Redis hashes, Redis is more memory efficient. Depends on the use case.

    You should care about persistence and replication, two features only available in Redis. Even if your goal is to build a cache it helps that after an upgrade or a reboot your data are still there.

    You should care about the kind of operations you need. In Redis there are a lot of complex operations, even just considering the caching use case, you often can do a lot more in a single operation, without requiring data to be processed client side (a lot of I/O is sometimes needed). This operations are often as fast as plain GET and SET. So if you don’t need just GEt/SET but more complex things Redis can help a lot (think at timeline caching).


四、总结

在今日开讲的项目中,Redis主要是用于保存首页配置和session数据(用于分布式),在和研究MemCache的姑娘交流过后,对于之前为什么没有选择MemCache的问题,事实上还是没能获得解决。而且对于内存销毁的配置问题,也是有自己的一些看法,下午找人交流一下。或者,我需要去弄几本书看看。但是就目前的理解来说,如果是小数据范围的快速读写,那么用Redis应该是一个不错的选择。

下一篇博客,介绍一下具体的使用!



转载于:https://www.cnblogs.com/hhx626/p/6010337.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值