diff --git a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/RedisLocalStorageClient.java b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/RedisLocalStorageClient.java index 7779150a2..e308648ae 100644 --- a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/RedisLocalStorageClient.java +++ b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/RedisLocalStorageClient.java @@ -25,6 +25,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static com.netease.nim.camellia.redis.proxy.upstream.local.storage.constants.LocalStorageConstants.key_max_len; + /** * Created by caojiajun on 2025/1/3 */ @@ -62,7 +64,7 @@ public void sendCommand(int db, List commands, List keys = command.getKeys(); for (byte[] key : keys) { - if (key.length > 1024) { + if (key.length > key_max_len) { future.complete(ErrorReply.KEY_TOO_LONG); return; } diff --git a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/compact/CompactExecutor.java b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/compact/CompactExecutor.java index 662fa3450..5a098f353 100644 --- a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/compact/CompactExecutor.java +++ b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/compact/CompactExecutor.java @@ -100,7 +100,7 @@ public void compact(short slot) { recycle = decodeResult.remaining() > BlockType._32k.getBlockSize(); } else if (blockType == BlockType._1024k) { recycle = decodeResult.remaining() > BlockType._256k.getBlockSize(); - } else if (blockType == BlockType._10m) { + } else if (blockType == BlockType._8m) { recycle = decodeResult.remaining() > BlockType._1024k.getBlockSize(); } } @@ -151,8 +151,8 @@ private BlockType nextBlockType(short slot) { case _4k -> nextBlockTypeMap.put(slot, BlockType._32k); case _32k -> nextBlockTypeMap.put(slot, BlockType._256k); case _256k -> nextBlockTypeMap.put(slot, BlockType._1024k); - case _1024k -> nextBlockTypeMap.put(slot, BlockType._10m); - case _10m -> nextBlockTypeMap.put(slot, BlockType._4k); + case _1024k -> nextBlockTypeMap.put(slot, BlockType._8m); + case _8m -> nextBlockTypeMap.put(slot, BlockType._4k); } return blockType; } diff --git a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/constants/LocalStorageConstants.java b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/constants/LocalStorageConstants.java index fd2946567..a5c0520cf 100644 --- a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/constants/LocalStorageConstants.java +++ b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/constants/LocalStorageConstants.java @@ -5,12 +5,14 @@ */ public class LocalStorageConstants { + public static final int key_max_len = 1024; + public static final int _4k = 4*1024; public static final int _32k = 32*1024; public static final int _64k = 64*1024; public static final int _256k = 256*1024; public static final int _1024k = 1024*1024; - public static final int _10m = 10*1024*1024; + public static final int _8m = 8*1024*1024; public static final int key_manifest_bit_size = (int)(16*1024*1024*1024L / _64k);//16Gib public static final long data_file_size = 192*1024*1024*1024L;//128Gib public static final int block_header_len = 4+4+2+1+4+4; diff --git a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/block/BlockType.java b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/block/BlockType.java index 6254113a4..c170667d3 100644 --- a/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/block/BlockType.java +++ b/camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/local/storage/value/block/BlockType.java @@ -11,7 +11,7 @@ public enum BlockType { _32k(2, 32*1024, 2), _256k(3, 256*1024, 4), _1024k(4, 1024*1024, 4), - _10m(5, 10*1024*1024, 4), + _8m(5, 8*1024*1024, 4), ; private final int type; @@ -54,8 +54,8 @@ public static BlockType fromData(byte[] data) { return BlockType._256k; } else if (data.length + 4 + 4 < LocalStorageConstants._1024k) { return BlockType._1024k; - } else if (data.length + 4 + 4 < LocalStorageConstants._10m) { - return BlockType._10m; + } else if (data.length + 4 + 4 < LocalStorageConstants._8m) { + return BlockType._8m; } else { throw new IllegalArgumentException("data too long"); }