Redis Learning

应用场景:
redis 适用于小而热的数据

github上的scala版redis client
官方推荐了好几款开源的scala 版客户端,都不知道选哪个比较好了,应该迅速读一遍scala 并发编程


Redis is an open source(BSD Licensed),in-memory data structure store,
used as a 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.
build-in:

in-memory dataset:

In order to achieve its outstanding performance, Redis works with an in-memory dataset. Depending on your use case, you can persist it either by dumping the dataset to disk every once in a while, or by appending each command to a log. Persistence can be optionally disabled, if you just need a feature-rich, networked, in-memory cache.

no-blocking replication:

Redis also supports trivial-to-setup master-slave asynchronous replication, with very fast non-blocking first synchronization, auto-reconnection with partial resynchronization on net split.

transcation数据库事务
彻底搞懂事务

6379-为何Redis选择它作为默认端口号?
redis 使用服务器端/客户端架构的数据库架构
通过client去连接redis服务端

  • 我们可以通过redis-cli去连接redis数据库,这是学习测试redis最好的方法,这时redis-cli就是一个client
  • 之前连接关系型数据库一般都是通过JDBC的方式连接的,这个redis是怎么连接上去的我暂时还没有搞清楚,官方推荐了很多类似与sdk的工具库,使用这些库可以很方便的连接redis,

  • redis 持久化
    有两种方式做持久化,其一是RDB,定期备份数据库的状态;其二是AOF,记录数据库的相关命令
    优先使用AOF方式


使用list来存储数据,LPUSH mylist "1"
// BRPOP mylist 0 取出最先放入的元素,
每分钟生成一个key,同步数据只处理之前的key里面的数据
做一个事务,保证该元素处理的原子性
因为BRPOP 只能取出最后一个元素,所以应该使用BPOPLPUSH


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值