西维蜀黍

【Distributed System】事务消息(Transactional-Message-Based Distributed Transactions)

事务消息 Transactional-Message-Based Distributed Transactions

事务消息就是今天文章的主角了,它主要是适用于异步更新的场景,并且对数据实时性要求不高的地方

它的目的是为了解决消息生产者与消息消费者的数据一致性问题。

  ...


【Cache System】缓存一致性 - Solution Discussion

策略1 - 先更新数据库,再更新缓存

分析一(线程安全角度)

同时有请求A和请求B进行更新操作,那么会出现

  1. 线程A更新了数据库
  2. 线程B更新了数据库
  3. 线程B更新了缓存
  4. 线程A更新了缓存

一般来说,请求A更新缓存应该比请求B更新缓存早才对,但理论上,也可能因为网络等原因(虽然概率相对较低),B却比A更早更新了缓存。这就导致了脏数据。

  ...


【Engineering】Clean Code

  ...


【Engineering】信息烟囱(Information Silo)

烟囱式系统(Information Silo Architecture)

烟囱式系统(Information Silo Architecture),来自维基百科的解释是:一种不能与其他系统进行有效协调工作的信息系统,又称为孤岛系统。

比如:

假设淘宝和天猫,是两个大系统,忽略业务模式的不同,这两个系统里面都有用户管理、商品管理、订单管理、支付等功能模块,如下图,这样子的淘宝和天猫就好像两座烟囱各自矗立,互不关联。

  ...


【Engineering】Data Migration

Data migration

Data migration is the process of selecting, preparing, extracting, and transforming data and permanently transferring it from one computer storage system to another. Additionally, the validation of migrated data for completeness and the decommissioning of legacy data storage are considered part of the entire data migration process.

  ...


【Redis】使用 - zset

Add

ZADD

# Adds members with the given scores to the ZSET
ZADD key-name score member [score member …]
  ...


【Redis】数据类型的底层数据结构 - String

  ...


【Redis】数据类型的底层数据结构 - ZSet

跳跃表(跳表,Skiplist)

引言

Redis因为其完全基于内存、性能出色,加上具备丰富的数据类型,在电商环境中深受后端开发的喜爱。其中有序集合zset就是基本数据类型之一,并且每个member都带有score(可用于排序),因此很适合在打赏日榜、近一周收益这类场景中运用。

跳表的定义

跳表:增加了向前指针的链表叫做指针。跳表全称叫做跳跃表,简称跳表。跳表是一个随机化的数据结构,实质是一种可以进行二分查找的有序链表。跳表在原有的有序链表上增加了多级索引,通过索引来实现快速查询。跳表不仅能提高搜索性能,同时也可以提高插入和删除操作的性能。

跳表是一个随机化的数据结构,可以被看做二叉树的一个变种,它在性能上和红黑树、AVL树不相上下,但是跳表的原理非常简单,目前在Redis和LevelDB中都有用到。

  ...


【Hackintosh】硬件购买指南

网卡

Ref

  ...


【Golang】Prepared Statements in Golang

Background

What is a prepared statement?

A prepared statement is SQL that is parsed and saved by the DBMS, typically containing placeholders but with no actual parameter values. Later, the statement can be executed with a set of parameter values.

  ...