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

相关推荐
闲猫17 分钟前
go orm GORM
开发语言·后端·golang
丁卯40439 分钟前
Go语言中使用viper绑定结构体和yaml文件信息时,标签的使用
服务器·后端·golang
卑微的小鬼15 小时前
rpc和http的区别,为啥golang使用grpc 不使用http?
http·rpc·golang
大脑经常闹风暴@小猿17 小时前
1.1 go环境搭建及基本使用
开发语言·后端·golang
tekin20 小时前
Go、Java、Python、C/C++、PHP、Rust 语言全方位对比分析
java·c++·golang·编程语言对比·python 语言·php 语言·编程适用场景
zhoupenghui1681 天前
golang时间相关函数总结
服务器·前端·golang·time
孤雪心殇1 天前
简单易懂,解析Go语言中的Map
开发语言·数据结构·后端·golang·go
闲猫1 天前
go 反射 interface{} 判断类型 获取值 设置值 指针才可以设置值
开发语言·后端·golang·反射
Ciderw1 天前
LLVM编译器简介
c++·golang·编译·编译器·gcc·llvm·基础设施
朗迹 - 张伟1 天前
Golang连接使用SqlCipher
开发语言·后端·golang