# Command Implementation

# LUA

# Design Ideas

Redis design: one redis node maintains a LUA virtual machine, and sync script data to backup node by persisting them in rdb.

Bitalostored design: Bitalostored uses multiple LUA virtual machines. The LUA script chooses a special slot (2048) to store script to the disk, sync script data by raft log replication.

Note: The management backend cannot migrate LUA scripts. Slot 2048 needs to be migrated manually through migration command.

# Atomicity

Redis: When redis executes LUA scripts, other commands cannot be executed.

Bitalostored: When Bitalostored executes LUA scripts, other commands could be executed. When the LUA command contains multiple keys, the hash tag of all keys must be same. Atomicity is ensured by add lock for the modulus of the same hash tag.

# Bitmap

# Redis Implementation

In the bitmap implementation of redis, the size of the stored value is related to the size of the offset and has little to do with the number of stored bits. If the offset is 100 million, even if 1 bit is stored, it will occupy 12MB of space.

127.0.0.1:6379> setbit bit-demo 100000000 1
(integer) 0
127.0.0.1:6379> strlen bit-demo
(integer) 12500001

# Bitalos Implementation

In the bitmap implementation of bitalos, using compressed bitmap to store the same data as above, requiring only 30B of space.

127.0.0.1:8111> setbit bit-demo 100000000 1
(integer) 0
127.0.0.1:8111> strlen bit-demo
(integer) 30
ZUOYEBANG