NoSQL数据库Redis

缓存技术

cookie和session

Cookie:客户端保存用户信息的一种机制
Session:(会话控制)服务器端保存一个数据结构,用来追踪用户的状态,session对象存储特定用户会话所需的属性及配置信息。这个数据可以保存在集群、数据库、文件中。

Session维护用户登录状态过程:

用户提交登录表单,request

服务端校验用户名和密码

通过后把用户信息存储到redis中,key为session_id

server返回的respone中的set-cookie字段包含该session_id,client收到后存入cookie中,

client再次向服务器发送请求时,会在请求头中添加自己的cookie信息,server收到后提取出并在redis中找到该session,完成业务操作。

(多图下次补上)

sticky和non-sticky

sticky:粘性
non-sticky:非粘性

redis部署与使用

CentOS8中自带的yum仓库中的redis

[root@centos8 ~]#dnf info redis 
Last metadata expiration check: 0:00:16 ago on Wed 13 Jul 2022 05:08:31 AM CST.
Available Packages
Name         : redis
Version      : 5.0.3
Release      : 5.module_el8.4.0+955+7126e393
Architecture : x86_64
Size         : 927 k
Source       : redis-5.0.3-5.module_el8.4.0+955+7126e393.src.rpm
Repository   : appstream
Summary      : A persistent key-value database
URL          : http://redis.io
License      : BSD and MIT
Description  : Redis is an advanced key-value store. It is often referred to as a data
             : structure server since keys can contain strings, hashes, lists, sets and
             : sorted sets.
             : 
             : You can run atomic operations on these types, like appending to a string;
             : incrementing the value in a hash; pushing to a list; computing set
             : intersection, union and difference; or getting the member with highest
             : ranking in a sorted set.
             : 
             : 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.
             : 
             : Redis also supports trivial-to-setup master-slave replication, with very
             : fast non-blocking first synchronization, auto-reconnection on net split
             : and so forth.
             : 
             : Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
             : limited time-to-live, and configuration settings to make Redis behave like
             : a cache.
             : 
             : You can use Redis from most programming languages also.

编译安装

多实例

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值