Decorative image frame

Redis实现分布式锁

Redis一个比较重要的应用场景就是分布式锁DLM (Distributed Lock Manager)。实际上已经有很多现成的redis库来完成这个功能了,但是可能实现途径有所差别,那么,正确的做法是什么呢?Redis官方建议了一个算法叫做Redlock,可以将其作为起点去实现更复杂的方案,来研究一下它的思路。

Read More...

A brief introduction to MySQL binary log

Accroding to the mysql manual, the binary log( also known as binlog) is a very powerful feature that enables the recording of "events" that describe database changes. Those changes could be table modification or data change, and may also contain some statements which may potentially made changes such as DELETE which no matched items.

This kind of feature enables mysql in replication from master to slave servers by sending events contained in binlogs, and also data recovery. Except for that, it could also be used in CDC(change-data-capture) since it's event based, an example usage could be found in the cdc-component in Eventuate™.

Read More...

一个简单的ETL程序

这两天闲着没事准备玩一下社工库,网上有很多以前的社工库(这些都可以下载到,但是实际上已经没有什么太大的价值了,因为暴露时间太久,以及相关的网站都已经做了处理,所以别指望能够找到什么有价值的东西),通过社工库可以了解到的一个实际的数据就是,用户的设置的密码大都是什么样子的。我准备看一下搜云社工库,这个库大概4亿多条数据,主要目的是实践一下大量数据的处理。

Read More...

阅读笔记:ConcurrentHashMap

我们知道HashMap不是Thread-safe的,而HashTable内部采取了同步操作,是线程安全的。然而有趣的是你去看HashTable的文档,它会建议你:如果不要Thread-Safe你就用HashMap吧,否则你用ConcurrentHashMap好了。

一般如果对线程安全有要求,我们有如下的一些选择:

  • ConcurrentHashMap
  • Hashtable
  • Collections.synchronizedMap
Read More...