《使用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)

相关推荐
吴佳浩 Alben5 小时前
Gin 入门指南 Swagger aipfox集成
gin
Tony Bai5 小时前
Cloudflare 2025 年度报告发布——Go 语言再次“屠榜”API 领域,AI 流量激增!
开发语言·人工智能·后端·golang
小徐Chao努力9 小时前
Go语言核心知识点底层原理教程【变量、类型与常量】
开发语言·后端·golang
锥锋骚年9 小时前
go语言异常处理方案
开发语言·后端·golang
moxiaoran575312 小时前
Go语言的map
开发语言·后端·golang
小信啊啊12 小时前
Go语言数组
开发语言·后端·golang
IT艺术家-rookie12 小时前
golang-- sync.WaitGroup 和 errgroup.Group 详解
开发语言·后端·golang
树下水月12 小时前
Go语言编码规范
开发语言·后端·golang
laozhoy112 小时前
深入理解Golang中的锁机制
开发语言·后端·golang
moxiaoran575321 小时前
Go语言的范围range
golang