diff --git a/src/server/bitops_family.cc b/src/server/bitops_family.cc index 2145f9179cca..c80535cf350c 100644 --- a/src/server/bitops_family.cc +++ b/src/server/bitops_family.cc @@ -1360,27 +1360,16 @@ OpResult FindFirstBitWithValue(const OpArgs& op_args, string_view key, } // namespace -namespace acl { -constexpr uint32_t kBitPos = READ | BITMAP | SLOW; -constexpr uint32_t kBitCount = READ | BITMAP | SLOW; -constexpr uint32_t kBitField = WRITE | BITMAP | SLOW; -constexpr uint32_t kBitFieldRo = READ | BITMAP | FAST; -constexpr uint32_t kBitOp = WRITE | BITMAP | SLOW; -constexpr uint32_t kGetBit = READ | BITMAP | FAST; -constexpr uint32_t kSetBit = WRITE | BITMAP | SLOW; -} // namespace acl - void BitOpsFamily::Register(CommandRegistry* registry) { using CI = CommandId; - registry->StartFamily(); - *registry << CI{"BITPOS", CO::CommandOpt::READONLY, -3, 1, 1, acl::kBitPos}.SetHandler(&BitPos) - << CI{"BITCOUNT", CO::READONLY, -2, 1, 1, acl::kBitCount}.SetHandler(&BitCount) - << CI{"BITFIELD", CO::WRITE, -3, 1, 1, acl::kBitField}.SetHandler(&BitField) - << CI{"BITFIELD_RO", CO::READONLY, -5, 1, 1, acl::kBitFieldRo}.SetHandler(&BitFieldRo) - << CI{"BITOP", CO::WRITE | CO::NO_AUTOJOURNAL, -4, 2, -1, acl::kBitOp}.SetHandler( - &BitOp) - << CI{"GETBIT", CO::READONLY | CO::FAST, 3, 1, 1, acl::kGetBit}.SetHandler(&GetBit) - << CI{"SETBIT", CO::WRITE | CO::DENYOOM, 4, 1, 1, acl::kSetBit}.SetHandler(&SetBit); + registry->StartFamily(acl::BITMAP); + *registry << CI{"BITPOS", CO::CommandOpt::READONLY, -3, 1, 1}.SetHandler(&BitPos) + << CI{"BITCOUNT", CO::READONLY, -2, 1, 1}.SetHandler(&BitCount) + << CI{"BITFIELD", CO::WRITE, -3, 1, 1}.SetHandler(&BitField) + << CI{"BITFIELD_RO", CO::READONLY | CO::FAST, -5, 1, 1}.SetHandler(&BitFieldRo) + << CI{"BITOP", CO::WRITE | CO::NO_AUTOJOURNAL, -4, 2, -1}.SetHandler(&BitOp) + << CI{"GETBIT", CO::READONLY | CO::FAST, 3, 1, 1}.SetHandler(&GetBit) + << CI{"SETBIT", CO::WRITE | CO::DENYOOM, 4, 1, 1}.SetHandler(&SetBit); } } // namespace dfly diff --git a/src/server/bloom_family.cc b/src/server/bloom_family.cc index 98bfc3d78a28..86adf9f2350e 100644 --- a/src/server/bloom_family.cc +++ b/src/server/bloom_family.cc @@ -192,14 +192,12 @@ using CI = CommandId; #define HFUNC(x) SetHandler(&BloomFamily::x) void BloomFamily::Register(CommandRegistry* registry) { - registry->StartFamily(); - - *registry << CI{"BF.RESERVE", CO::WRITE | CO::DENYOOM | CO::FAST, -4, 1, 1, acl::BLOOM}.HFUNC( - Reserve) - << CI{"BF.ADD", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1, acl::BLOOM}.HFUNC(Add) - << CI{"BF.MADD", CO::WRITE | CO::DENYOOM | CO::FAST, -3, 1, 1, acl::BLOOM}.HFUNC(MAdd) - << CI{"BF.EXISTS", CO::READONLY | CO::FAST, 3, 1, 1, acl::BLOOM}.HFUNC(Exists) - << CI{"BF.MEXISTS", CO::READONLY | CO::FAST, -3, 1, 1, acl::BLOOM}.HFUNC(MExists); + registry->StartFamily(acl::BLOOM); + *registry << CI{"BF.RESERVE", CO::WRITE | CO::DENYOOM | CO::FAST, -4, 1, 1}.HFUNC(Reserve) + << CI{"BF.ADD", CO::WRITE | CO::DENYOOM | CO::FAST, 3, 1, 1}.HFUNC(Add) + << CI{"BF.MADD", CO::WRITE | CO::DENYOOM | CO::FAST, -3, 1, 1}.HFUNC(MAdd) + << CI{"BF.EXISTS", CO::READONLY | CO::FAST, 3, 1, 1}.HFUNC(Exists) + << CI{"BF.MEXISTS", CO::READONLY | CO::FAST, -3, 1, 1}.HFUNC(MExists); }; } // namespace dfly diff --git a/src/server/hll_family.cc b/src/server/hll_family.cc index c342855b9a89..ca6bba5cf053 100644 --- a/src/server/hll_family.cc +++ b/src/server/hll_family.cc @@ -309,19 +309,12 @@ void PFMerge(CmdArgList args, Transaction* tx, SinkReplyBuilder* builder) { } // namespace -namespace acl { -constexpr uint32_t kPFAdd = WRITE | HYPERLOGLOG | FAST; -constexpr uint32_t kPFCount = READ | HYPERLOGLOG | SLOW; -constexpr uint32_t kPFMerge = WRITE | HYPERLOGLOG | SLOW; -} // namespace acl - void HllFamily::Register(CommandRegistry* registry) { using CI = CommandId; - registry->StartFamily(); - *registry << CI{"PFADD", CO::WRITE, -3, 1, 1, acl::kPFAdd}.SetHandler(PFAdd) - << CI{"PFCOUNT", CO::READONLY, -2, 1, -1, acl::kPFCount}.SetHandler(PFCount) - << CI{"PFMERGE", CO::WRITE | CO::NO_AUTOJOURNAL, -2, 1, -1, acl::kPFMerge}.SetHandler( - PFMerge); + registry->StartFamily(acl::HYPERLOGLOG); + *registry << CI{"PFADD", CO::FAST | CO::WRITE, -3, 1, 1}.SetHandler(PFAdd) + << CI{"PFCOUNT", CO::READONLY, -2, 1, -1}.SetHandler(PFCount) + << CI{"PFMERGE", CO::WRITE | CO::NO_AUTOJOURNAL, -2, 1, -1}.SetHandler(PFMerge); } const char HllFamily::kInvalidHllErr[] = "Key is not a valid HyperLogLog string value."; diff --git a/src/server/list_family.cc b/src/server/list_family.cc index 2107c7c1820a..d111acaaaa64 100644 --- a/src/server/list_family.cc +++ b/src/server/list_family.cc @@ -1236,60 +1236,31 @@ using CI = CommandId; #define HFUNC(x) SetHandler(&ListFamily::x) -namespace acl { -constexpr uint32_t kLPush = WRITE | LIST | FAST; -constexpr uint32_t kLPushX = WRITE | LIST | FAST; -constexpr uint32_t kLPop = WRITE | LIST | FAST; -constexpr uint32_t kRPush = WRITE | LIST | FAST; -constexpr uint32_t kRPushX = WRITE | LIST | FAST; -constexpr uint32_t kRPop = WRITE | LIST | FAST; -constexpr uint32_t kRPopLPush = WRITE | LIST | SLOW; -constexpr uint32_t kBRPopLPush = WRITE | LIST | SLOW | BLOCKING; -constexpr uint32_t kBLPop = WRITE | LIST | SLOW | BLOCKING; -constexpr uint32_t kBRPop = WRITE | LIST | SLOW | BLOCKING; -constexpr uint32_t kLLen = READ | LIST | FAST; -constexpr uint32_t kLPos = READ | LIST | SLOW; -constexpr uint32_t kLIndex = READ | LIST | SLOW; -constexpr uint32_t kLInsert = READ | LIST | SLOW; -constexpr uint32_t kLRange = READ | LIST | SLOW; -constexpr uint32_t kLSet = WRITE | LIST | SLOW; -constexpr uint32_t kLTrim = WRITE | LIST | SLOW; -constexpr uint32_t kLRem = WRITE | LIST | SLOW; -constexpr uint32_t kLMove = WRITE | LIST | SLOW; -constexpr uint32_t kBLMove = READ | LIST | SLOW | BLOCKING; -} // namespace acl - void ListFamily::Register(CommandRegistry* registry) { - registry->StartFamily(); + registry->StartFamily(acl::LIST); *registry - << CI{"LPUSH", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1, acl::kLPush}.HFUNC(LPush) - << CI{"LPUSHX", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1, acl::kLPushX}.HFUNC(LPushX) - << CI{"LPOP", CO::WRITE | CO::FAST, -2, 1, 1, acl::kLPop}.HFUNC(LPop) - << CI{"RPUSH", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1, acl::kRPush}.HFUNC(RPush) - << CI{"RPUSHX", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1, acl::kRPushX}.HFUNC(RPushX) - << CI{"RPOP", CO::WRITE | CO::FAST, -2, 1, 1, acl::kRPop}.HFUNC(RPop) - << CI{"RPOPLPUSH", CO::WRITE | CO::FAST | CO::NO_AUTOJOURNAL, 3, 1, 2, acl::kRPopLPush} - .SetHandler(RPopLPush) - << CI{"BRPOPLPUSH", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, 4, 1, 2, - acl::kBRPopLPush} + << CI{"LPUSH", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1}.HFUNC(LPush) + << CI{"LPUSHX", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1}.HFUNC(LPushX) + << CI{"LPOP", CO::WRITE | CO::FAST, -2, 1, 1}.HFUNC(LPop) + << CI{"RPUSH", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1}.HFUNC(RPush) + << CI{"RPUSHX", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1}.HFUNC(RPushX) + << CI{"RPOP", CO::WRITE | CO::FAST, -2, 1, 1}.HFUNC(RPop) + << CI{"RPOPLPUSH", CO::WRITE | CO::NO_AUTOJOURNAL, 3, 1, 2}.SetHandler(RPopLPush) + << CI{"BRPOPLPUSH", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, 4, 1, 2} .SetHandler(BRPopLPush) - << CI{"BLPOP", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, -3, 1, -2, - acl::kBLPop} - .HFUNC(BLPop) - << CI{"BRPOP", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, -3, 1, -2, - acl::kBRPop} - .HFUNC(BRPop) - << CI{"LLEN", CO::READONLY | CO::FAST, 2, 1, 1, acl::kLLen}.HFUNC(LLen) - << CI{"LPOS", CO::READONLY | CO::FAST, -3, 1, 1, acl::kLPos}.HFUNC(LPos) - << CI{"LINDEX", CO::READONLY, 3, 1, 1, acl::kLIndex}.HFUNC(LIndex) - << CI{"LINSERT", CO::WRITE | CO::DENYOOM, 5, 1, 1, acl::kLInsert}.HFUNC(LInsert) - << CI{"LRANGE", CO::READONLY, 4, 1, 1, acl::kLRange}.HFUNC(LRange) - << CI{"LSET", CO::WRITE | CO::DENYOOM, 4, 1, 1, acl::kLSet}.HFUNC(LSet) - << CI{"LTRIM", CO::WRITE, 4, 1, 1, acl::kLTrim}.HFUNC(LTrim) - << CI{"LREM", CO::WRITE, 4, 1, 1, acl::kLRem}.HFUNC(LRem) - << CI{"LMOVE", CO::WRITE | CO::NO_AUTOJOURNAL, 5, 1, 2, acl::kLMove}.HFUNC(LMove) - << CI{"BLMOVE", CO::WRITE | CO::NO_AUTOJOURNAL | CO::BLOCKING, 6, 1, 2, acl::kBLMove} - .SetHandler(BLMove); + << CI{"BLPOP", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, -3, 1, -2}.HFUNC( + BLPop) + << CI{"BRPOP", CO::WRITE | CO::NOSCRIPT | CO::BLOCKING | CO::NO_AUTOJOURNAL, -3, 1, -2}.HFUNC( + BRPop) + << CI{"LLEN", CO::READONLY | CO::FAST, 2, 1, 1}.HFUNC(LLen) + << CI{"LPOS", CO::READONLY, -3, 1, 1}.HFUNC(LPos) + << CI{"LINDEX", CO::READONLY, 3, 1, 1}.HFUNC(LIndex) + << CI{"LINSERT", CO::WRITE | CO::DENYOOM, 5, 1, 1}.HFUNC(LInsert) + << CI{"LRANGE", CO::READONLY, 4, 1, 1}.HFUNC(LRange) + << CI{"LSET", CO::WRITE | CO::DENYOOM, 4, 1, 1}.HFUNC(LSet) + << CI{"LTRIM", CO::WRITE, 4, 1, 1}.HFUNC(LTrim) << CI{"LREM", CO::WRITE, 4, 1, 1}.HFUNC(LRem) + << CI{"LMOVE", CO::WRITE | CO::NO_AUTOJOURNAL, 5, 1, 2}.HFUNC(LMove) + << CI{"BLMOVE", CO::WRITE | CO::NO_AUTOJOURNAL | CO::BLOCKING, 6, 1, 2}.SetHandler(BLMove); } } // namespace dfly diff --git a/src/server/search/search_family.cc b/src/server/search/search_family.cc index c710d03f569c..04ae5761dd9a 100644 --- a/src/server/search/search_family.cc +++ b/src/server/search/search_family.cc @@ -983,19 +983,17 @@ void SearchFamily::Register(CommandRegistry* registry) { const uint32_t kReadOnlyMask = CO::NO_KEY_TRANSACTIONAL | CO::NO_KEY_TX_SPAN_ALL | CO::NO_AUTOJOURNAL; - registry->StartFamily(); - *registry << CI{"FT.CREATE", CO::WRITE | CO::GLOBAL_TRANS, -2, 0, 0, acl::FT_SEARCH}.HFUNC( - FtCreate) - << CI{"FT.ALTER", CO::WRITE | CO::GLOBAL_TRANS, -3, 0, 0, acl::FT_SEARCH}.HFUNC(FtAlter) - << CI{"FT.DROPINDEX", CO::WRITE | CO::GLOBAL_TRANS, -2, 0, 0, acl::FT_SEARCH}.HFUNC( - FtDropIndex) - << CI{"FT.INFO", kReadOnlyMask, 2, 0, 0, acl::FT_SEARCH}.HFUNC(FtInfo) + registry->StartFamily(acl::FT_SEARCH); + *registry << CI{"FT.CREATE", CO::WRITE | CO::GLOBAL_TRANS, -2, 0, 0}.HFUNC(FtCreate) + << CI{"FT.ALTER", CO::WRITE | CO::GLOBAL_TRANS, -3, 0, 0}.HFUNC(FtAlter) + << CI{"FT.DROPINDEX", CO::WRITE | CO::GLOBAL_TRANS, -2, 0, 0}.HFUNC(FtDropIndex) + << CI{"FT.INFO", kReadOnlyMask, 2, 0, 0}.HFUNC(FtInfo) // Underscore same as in RediSearch because it's "temporary" (long time already) - << CI{"FT._LIST", kReadOnlyMask, 1, 0, 0, acl::FT_SEARCH}.HFUNC(FtList) - << CI{"FT.SEARCH", kReadOnlyMask, -3, 0, 0, acl::FT_SEARCH}.HFUNC(FtSearch) - << CI{"FT.AGGREGATE", kReadOnlyMask, -3, 0, 0, acl::FT_SEARCH}.HFUNC(FtAggregate) - << CI{"FT.PROFILE", kReadOnlyMask, -4, 0, 0, acl::FT_SEARCH}.HFUNC(FtProfile) - << CI{"FT.TAGVALS", kReadOnlyMask, 3, 0, 0, acl::FT_SEARCH}.HFUNC(FtTagVals); + << CI{"FT._LIST", kReadOnlyMask, 1, 0, 0}.HFUNC(FtList) + << CI{"FT.SEARCH", kReadOnlyMask, -3, 0, 0}.HFUNC(FtSearch) + << CI{"FT.AGGREGATE", kReadOnlyMask, -3, 0, 0}.HFUNC(FtAggregate) + << CI{"FT.PROFILE", kReadOnlyMask, -4, 0, 0}.HFUNC(FtProfile) + << CI{"FT.TAGVALS", kReadOnlyMask, 3, 0, 0}.HFUNC(FtTagVals); } } // namespace dfly diff --git a/src/server/set_family.cc b/src/server/set_family.cc index 9204633b2124..b39ba3b6cd84 100644 --- a/src/server/set_family.cc +++ b/src/server/set_family.cc @@ -1483,53 +1483,29 @@ using CI = CommandId; #define HFUNC(x) SetHandler(&x) -namespace acl { -constexpr uint32_t kSAdd = WRITE | SET | FAST; -constexpr uint32_t kSDiff = READ | SET | SLOW; -constexpr uint32_t kSDiffStore = WRITE | SET | SLOW; -constexpr uint32_t kSInter = READ | SET | SLOW; -constexpr uint32_t kSInterStore = WRITE | SET | SLOW; -constexpr uint32_t kSInterCard = READ | SET | SLOW; -constexpr uint32_t kSMembers = READ | SET | SLOW; -constexpr uint32_t kSIsMember = READ | SET | SLOW; -constexpr uint32_t kSMIsMember = READ | SET | FAST; -constexpr uint32_t kSMove = WRITE | SET | FAST; -constexpr uint32_t kSRem = WRITE | SET | FAST; -constexpr uint32_t kSCard = READ | SET | FAST; -constexpr uint32_t kSPop = WRITE | SET | SLOW; -constexpr uint32_t kSRandMember = READ | SET | SLOW; -constexpr uint32_t kSUnion = READ | SET | SLOW; -constexpr uint32_t kSUnionStore = WRITE | SET | SLOW; -constexpr uint32_t kSScan = READ | SET | SLOW; -} // namespace acl - void SetFamily::Register(CommandRegistry* registry) { - registry->StartFamily(); - *registry - << CI{"SADD", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1, acl::kSAdd}.HFUNC(SAdd) - << CI{"SDIFF", CO::READONLY, -2, 1, -1, acl::kSDiff}.HFUNC(SDiff) - << CI{"SDIFFSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1, acl::kSDiffStore} - .HFUNC(SDiffStore) - << CI{"SINTER", CO::READONLY, -2, 1, -1, acl::kSInter}.HFUNC(SInter) - << CI{"SINTERSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1, - acl::kSInterStore} - .HFUNC(SInterStore) - << CI{"SINTERCARD", CO::READONLY | CO::VARIADIC_KEYS, -3, 2, 2, acl::kSInterCard}.HFUNC( - SInterCard) - << CI{"SMEMBERS", CO::READONLY, 2, 1, 1, acl::kSMembers}.HFUNC(SMembers) - << CI{"SISMEMBER", CO::FAST | CO::READONLY, 3, 1, 1, acl::kSIsMember}.HFUNC(SIsMember) - << CI{"SMISMEMBER", CO::READONLY, -3, 1, 1, acl::kSMIsMember}.HFUNC(SMIsMember) - << CI{"SMOVE", CO::FAST | CO::WRITE | CO::NO_AUTOJOURNAL, 4, 1, 2, acl::kSMove}.HFUNC(SMove) - << CI{"SREM", CO::WRITE | CO::FAST, -3, 1, 1, acl::kSRem}.HFUNC(SRem) - << CI{"SCARD", CO::READONLY | CO::FAST, 2, 1, 1, acl::kSCard}.HFUNC(SCard) - << CI{"SPOP", CO::WRITE | CO::FAST | CO::NO_AUTOJOURNAL, -2, 1, 1, acl::kSPop}.HFUNC(SPop) - << CI{"SRANDMEMBER", CO::READONLY, -2, 1, 1, acl::kSRandMember}.HFUNC(SRandMember) - << CI{"SUNION", CO::READONLY, -2, 1, -1, acl::kSUnion}.HFUNC(SUnion) - << CI{"SUNIONSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1, - acl::kSUnionStore} - .HFUNC(SUnionStore) - << CI{"SSCAN", CO::READONLY, -3, 1, 1, acl::kSScan}.HFUNC(SScan) - << CI{"SADDEX", CO::WRITE | CO::FAST | CO::DENYOOM, -4, 1, 1, acl::kSAdd}.HFUNC(SAddEx); + registry->StartFamily(acl::SET); + *registry << CI{"SADD", CO::WRITE | CO::FAST | CO::DENYOOM, -3, 1, 1}.HFUNC(SAdd) + << CI{"SDIFF", CO::READONLY, -2, 1, -1}.HFUNC(SDiff) + << CI{"SDIFFSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1}.HFUNC( + SDiffStore) + << CI{"SINTER", CO::READONLY, -2, 1, -1}.HFUNC(SInter) + << CI{"SINTERSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1}.HFUNC( + SInterStore) + << CI{"SINTERCARD", CO::READONLY | CO::VARIADIC_KEYS, -3, 2, 2}.HFUNC(SInterCard) + << CI{"SMEMBERS", CO::READONLY, 2, 1, 1}.HFUNC(SMembers) + << CI{"SISMEMBER", CO::FAST | CO::READONLY, 3, 1, 1}.HFUNC(SIsMember) + << CI{"SMISMEMBER", CO::FAST | CO::READONLY, -3, 1, 1}.HFUNC(SMIsMember) + << CI{"SMOVE", CO::FAST | CO::WRITE | CO::NO_AUTOJOURNAL, 4, 1, 2}.HFUNC(SMove) + << CI{"SREM", CO::WRITE | CO::FAST, -3, 1, 1}.HFUNC(SRem) + << CI{"SCARD", CO::READONLY | CO::FAST, 2, 1, 1}.HFUNC(SCard) + << CI{"SPOP", CO::WRITE | CO::FAST | CO::NO_AUTOJOURNAL, -2, 1, 1}.HFUNC(SPop) + << CI{"SRANDMEMBER", CO::READONLY, -2, 1, 1}.HFUNC(SRandMember) + << CI{"SUNION", CO::READONLY, -2, 1, -1}.HFUNC(SUnion) + << CI{"SUNIONSTORE", CO::WRITE | CO::DENYOOM | CO::NO_AUTOJOURNAL, -3, 1, -1}.HFUNC( + SUnionStore) + << CI{"SSCAN", CO::READONLY, -3, 1, 1}.HFUNC(SScan) + << CI{"SADDEX", CO::WRITE | CO::FAST | CO::DENYOOM, -4, 1, 1}.HFUNC(SAddEx); } uint32_t SetFamily::MaxIntsetEntries() {