《使用Gin框架构建分布式应用》阅读笔记:p108-p126

《用Gin框架构建分布式应用》学习第8天,p108-p126总结,总计18页。

一、技术总结

1.Redis eviction policy

(1)什么是 eviction policy?

The eviction policy determines what happens when a database reaches its memory limit.

(2)配置示例

在redis.conf中配置。

复制代码
maxmemory-policy allkeys-lru

maxmemory 512mb

(3)参考资料

https://redis.io/docs/latest/operate/rs/databases/memory-performance/eviction-policy/。

2.Redis缓存刷新

使用缓存后会引入一个问题:当数据库的数据更新后(新增、修改、删除),如何保证数据的一致性(缓存里面的数据和数据库里面的数据是一样的)?即我们平常所说的"缓存刷新"。Redis 缓存刷新逻辑一般是两个方向:

(1)设置TTL(Time To Live)

TTL设置为多长,取决于具体业务,这里不展开讨论。

(2)新增的时候更新

当有数据更新的时候,删除掉缓存。

3.Redis GUI工具

(1)Redis Insight

Redis Insights (https://github.com/RedisInsight/RedisInsight)是书里面提到的Redis官方的GUI,试了下,不好用------比如选择某个库,得手动输入;值转换成JSON,得加载全部才能转,较麻烦。

(2)Another Redis Desktop Manager

ADRM(https://github.com/qishibo/AnotherRedisDesktopManager)是本人在实际工作中使用的GUI工具,本人更倾向于使用这个。

4.performence benchmark

(1)Apache Benchmark

Apache Benchmark使用详见:https://httpd.apache.org/docs/2.4/programs/ab.html。

(2)gnuplot

本人也是第一次听说 Apache 和 gnuplot,这里 mark 一下。

二、英语总结

1.eviction

p108, For production usage, it's recommends to configure an eviction policy.

(1)eviction:evict的名词形式。

(2)evict: e-(out, away) + vincere("conquer")。vt. to force sb to leave somewhere(驱逐).

evict的本意是驱逐,在Redis里面,"eviction policy"算是一种比喻用法。In computing, "evict" is used metaphorically, as if the data is being "forced out" of memory, similar to how a person might be evicted from a property.

2.wicked

As we can see, retrieving data from memory (Redis) is wicked fast compared to retrieving

data from disk (MongoDB).

wicked 既可以做形容词,可以做副词,这里的用法是做副词。

3.work like a charm

这是一个惯用语(idom),意为"to work very well"。

三、其它

有时候总想着快速掌握这些编程技能,而从这么多年的编程工作经历看,"掌握"只是一个结果,我们需要注重的是过程。就如这一刻,在阅读这本书的过程中,当进展顺利时,我知道自己掌握了这些知识点,而当遇到问题时,我知道这是因为自己还没有掌握了或者说还不够熟练,那么自己如何解决这些问题?这才是重点。每天阅读的进度有时快,有时慢,而怎样才能保证一个最基本的阅读量,这是我们在阅读过程中需要去思考的,需要去实践的。

四、参考资料

1. 编程

(1) Mohamed Labouardy,《Building Distributed Applications in Gin》:https://book.douban.com/subject/35610349

2. 英语

(1) Etymology Dictionary:https://www.etymonline.com

(2) Cambridge Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

相关推荐
ん贤13 小时前
如何加快golang编译速度
后端·golang·go
riverz122714 小时前
Go 程序无法使用 /etc/resolv.conf 的 DNS 配置排查记录
golang
As_wind_18 小时前
Go 语言学习之测试
开发语言·学习·golang
爬也要爬着前进1 天前
第十四章 gin基础
gin
Code季风1 天前
从内存机制到代码实现:深拷贝与浅拷贝深度解析
性能优化·go·gin
linweidong1 天前
Go语言时间控制:定时器技术详细指南
后端·golang·go定时器·go开发·go面试·go分布式·go timer
一条闲鱼_mytube2 天前
gin go-kratos go-zero框架对比
开发语言·golang·gin
come112343 天前
Go 包管理工具详解:安装与使用指南
开发语言·后端·golang
西京刀客3 天前
构建 Go 可执行文件镜像 | 探索轻量级 Docker 基础镜像(我应该选择哪个 Docker 镜像?)
开发语言·docker·golang
007php0073 天前
服务器上PHP环境安装与更新版本和扩展(安装PHP、Nginx、Redis、Swoole和OPcache)
运维·服务器·后端·nginx·golang·测试用例·php