Home > Database > Mysql Tutorial > body text

Redis 与Mysql通信

WBOY
Release: 2016-06-07 15:25:17
Original
1410 people have browsed it

找了点资料看了下。学习心得如下: 1 Mysql更新Redis Mysql更新Redis借鉴memcache与mysql通信,利用mysql udf,每有更新操作触发更新redis操作。不足在高并发时mysql压力较大,且针对每张表均需增删改触发,且Redis服务器不好更换(不知道有没有方法)。 2 R

找了点资料看了下。学习心得如下:

1 Mysql更新Redis

   Mysql更新Redis借鉴memcache与mysql通信,利用mysql udf,每有更新操作触发更新redis操作。不足在高并发时mysql压力较大,且针对每张表均需增删改触发,且Redis服务器不好更换(不知道有没有方法)。

2 Redis更新Mysql

 最简单的就是读redis->写mysql.但是在高并发下,这样就不太适合了,因此考虑利用消息队列每隔的固定时间更新Mysql。

但是数据中主键为自增时,目前想法如下:

   第一,Redis采用tempId为key,id为空,通过mysql udf重写数据到缓存如 ,清空缓存临时数据。

  第二,redis key值不采用Id,采用字段uuid,再通过mysql udf 同步redis缓存 id。

   第三,Redis读取Mysql表最新自增键Id值,Redis传递id。

 

Redis更新Mysql需注意,Redis在系统中的定位,作缓存服务器时,需规划存储哪些数据,保存多长时间等等。
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!