map的读写删除都不是原子操作,因此需要控制并发访问,而Go的原生map不支持并发读写;Go在1.9的版本中新增了sync.Map的数据结构,两个map实现分离。
不会引发扩容的操作(查,改)使用read map,可能引发扩容操作(新增)使用 dirty map。
读写 read 并不需要加锁,而读或写 dirty 则需要加锁。
适合读多 append 少的场景,其实是读写和追加分离。
map的读写删除都不是原子操作,因此需要控制并发访问,而Go的原生map不支持并发读写;Go在1.9的版本中新增了sync.Map的数据结构,两个map实现分离。
不会引发扩容的操作(查,改)使用read map,可能引发扩容操作(新增)使用 dirty map。
读写 read 并不需要加锁,而读或写 dirty 则需要加锁。
适合读多 append 少的场景,其实是读写和追加分离。
hashMap一般有两个实现方案:开放寻址法(往后错位)和拉链法(槽内是链表)。
slice 切片,也可以理解为动态数组。与数组相比切片的长度是不固定的,可以追加元素,在追加时可能使切片的容量增大。
每次都被 defer
,panic
和recover
坑的死去活来,今天抽出时间来整理一下。
(软件包安装的单元)
The expectation is that /lib/systemd/system
is a directory that should only contain systemd unit files which were put there by the package manager (YUM/DNF/RPM/APT/etc).
(系统管理员安装的单元, 优先级更高)
Files in /etc/systemd/system
are manually placed here by the operator of the system for ad-hoc software installations that are not in the form of a package. This would include tarball type software installations or home grown scripts.
记录一下 pgsql 的使用。