Developer Weekly 15

使用 JavaScript,将一个哈希值转成 SVG 图形
the-rise-and-fall-of-the-olap-cube
热重载指的是,在不重启的情况下更新应用。脚本语言都能支持这个功能,本文通俗地讲解,如何让 C 语言这样的编译语言,也支持热重载。
boltdb 源码分析
LSM-Tree 与 LevelDB 的原理和实现
深入理解什么是LSM-Tree
LevelDB 源码分析
如何用Netty写一个高性能的分布式服务框架?
Althttpd is a simple webserver
深入剖析Linux IO原理和几种零拷贝机制的实现
Linux I/O 原理和 Zero-copy 技术全面揭秘
技术文章摘抄
前沿 | 最快KV引擎!存储顶会FAST’20论文揭秘Tair创新性引擎
平衡二叉树、B树、B+树、B树 理解其中一种你就都明白了
二叉树、平衡二叉树、红黑树、B树、B+树与B

Project Loom: Java on Fiber
Go语言之禅
Implementing a world fastest Java int-to-int hash map*
Replicate your Key Value Store across your network, with consistency, persistance and performance.
Packet Traveling
Off-heap memory in Java
Spring Boot Memory Performance

心经

心经原文:
观自在菩萨,行深般若波罗蜜多时,照见五蕴皆空,渡一切苦厄。

舍利子!色不异空,空不异色;色即是空,空即是色;受想行识,亦复如是。

舍利子!是诸法空相,不生不灭,不垢不净,不增不减。

是故空中无色,无受想行识,无眼耳鼻舌身意,无色声香味触法,无眼界,乃至无意识界。

无无明,亦无无明尽,乃至无老死,亦无老死尽,无苦集灭道。无智亦无得。

以无所得故,菩提萨埵,依般若波罗蜜多故,心无罣碍,无罣碍故,无有恐怖, 远离颠倒梦想,究竟涅槃。

三世诸佛,依般若波罗蜜多故,得阿耨多罗三藐三菩提。

故知般若波罗蜜多,是大神咒,是大明咒,是无上咒,是无等等咒,能除一切苦,真实不虚。

故说般若波罗蜜多咒,即说咒曰︰揭諦揭諦,波罗揭諦,波罗僧揭諦,菩提娑婆呵。

Developer Weekly 14

从零开始写数据库:500行代码实现 LSM 数据库
从零开始写KV数据库:基于哈希索引
Java 日志框架冲突问题排查与总结
使用 Rust 构建分布式 Key-Value Store
Open source racing game developed by everyone willing
Flink教程
聊聊MyBatis缓存机制
Caching of MyBatis query results
Understanding LSM Trees: What Powers Write-Heavy Databases
You Complete Me
Magician | 异步非阻塞的网络协议解析包
CAP 定理解读
HTTP 安全标头快速参考
Java 堆外内存、零拷贝、直接内存以及针对于NIO中的FileChannel的思考
Redis高级客户端Lettuce详解
你真的了解Flink Kafka source吗?
Understanding Java Microbenchmark Harness or JMH Tool
Lessons Learned While Implementing a B+Tree
Pogreb – key-value store for read-heavy workloads
Replicate your Key Value Store across your network, with consistency, persistance and performance.
Hello World剧情分析
分布式哈希表 (DHT) 和 P2P 技术
IPFS白皮书 中文版
使用Apache Druid进行海量数据的存储与查询
实时统计分析系统-Apache Druid
异地多活paxos实现:Multi-Master-Paxos-3

龟虽寿

神龟虽寿,犹有竟时。螣蛇乘雾,终为土灰。老骥伏枥,志在千里。烈士暮年,壮心不已。盈缩之期,不但在天。养怡之福,可得永年。幸甚至哉,歌以咏志。

store ip ranges in Redis

store ip ranges in Redis

It depends if you consider your IP ranges can overlap or not. If not, the solution is quite simple:

      use a collection of hash to store providers data
      use a zset to index the max value of your ranges
      retrieve the (unique) range whose max value is greater than an IP
      check the the min value of this range is lower than the IP

Example:

Here are my providers. Each of them are identified with an id. Please note I could add more properties attached to each provider:

hmset providers:1 name P1 min 3232235786 max 3232235826
OK
hmset providers:2 name P3 min 1232235786 max 1232235826
OK
hmset providers:3 name P3 min 2232235786 max 2232235826
OK
hmset providers:4 name P4 min 4232235786 max 4232235826
OK

Each time a provider is added in the system, an index must be maintained (manually: this is Redis, not a relational database). Score is the max value, member is the id of the range.

zadd providers:index 3232235826 1 1232235826 2 2232235826 3 4232235826 4
(integer) 4
zrange providers:index 0 -1
1) "2"
2) "3"
3) "1"
4) "4"

Now to query the unique range corresponding to an IP address, you need 2 roundtrips:

zrangebyscore providers:index 3232235787 +inf LIMIT 0 1
1) "1"
hgetall providers:1
1) "name"
2) "P1"
3) "min"
4) "3232235786"
5) "max"
6) "3232235826"

Then the client program just has to check that your IP is greater or equal than the minimum address of the returned range.