Repository: microsoft/garnet
File: libs/server/Transaction/TxnKeyManager.cs (C#)

Code before:
                RespCommand.EXPIRE => SingleKey(1, false, LockType.Exclusive),
                RespCommand.PEXPIRE => SingleKey(1, false, LockType.Exclusive),
                RespCommand.PERSIST => SingleKey(1, false, LockType.Exclusive),
                RespCommand.MGET => ListKeys(inputCount, false, LockType.Shared),
                RespCommand.MSET => MSETKeys(inputCount, false, LockType.Exclusive),
                RespCommand.MSETNX => MSETKeys(inputCount, false, LockType.Exclusive),
                RespCommand.UNLINK => ListKeys(inputCount, false, LockType.Exclusive),
                RespCommand.GETDEL => SingleKey(1, false, LockType.Exclusive),
                RespCommand.APPEND => SingleKey(1, false, LockType.Exclusive),
                _ => AdminCommands(command)
            };
        }

        private static int AdminCommands(RespCommand command)
        {
            return command switch
            {
                RespCommand.ECHO => 1,
                RespCommand.REPLICAOF => 1,
                RespCommand.SECONDARYOF => 1,
                RespCommand.CONFIG => 1,
                RespCommand.CLIENT => 1,
                RespCommand.PING => 1,
                RespCommand.PUBLISH => 1,
                RespCommand.SPUBLISH => 1,
                _ => -1
            };
        }

        private int SortedSetObjectKeys(SortedSetOperation command, int inputCount)
        {

            return command switch
            {
                SortedSetOperation.ZADD => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREM => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZCARD => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZPOPMAX => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZSCORE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZMSCORE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZCOUNT => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZINCRBY => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZRANGE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZREVRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYLEX => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYSCORE => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZLEXCOUNT => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZPOPMIN => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZRANDMEMBER => SingleKey(1, true, LockType.Exclusive),

Review comment (suggestion):
Unrelated to this PR... Not sure why this method is called AdminCommands, none of these commands are admin commands. Should maybe be renamed to KeylessCommands? GetKeys is also confusing, it doesn't even describe what the method does...

Code after:
                RespCommand.EXPIRE => SingleKey(1, false, LockType.Exclusive),
                RespCommand.PEXPIRE => SingleKey(1, false, LockType.Exclusive),
                RespCommand.PERSIST => SingleKey(1, false, LockType.Exclusive),
                RespCommand.MGET => ListKeys(inputCount, false, LockType.Shared),
                RespCommand.MSET => MSETKeys(inputCount, false, LockType.Exclusive),
                RespCommand.MSETNX => MSETKeys(inputCount, false, LockType.Exclusive),
                RespCommand.UNLINK => ListKeys(inputCount, false, LockType.Exclusive),
                RespCommand.GETDEL => SingleKey(1, false, LockType.Exclusive),
                RespCommand.APPEND => SingleKey(1, false, LockType.Exclusive),
                _ => AdminCommands(command)
            };
        }

        private static int AdminCommands(RespCommand command)
        {
            return command switch
            {
                RespCommand.ECHO => 1,
                RespCommand.REPLICAOF => 1,
                RespCommand.SECONDARYOF => 1,
                RespCommand.CONFIG => 1,
                RespCommand.CLIENT => 1,
                RespCommand.PING => 1,
                RespCommand.PUBLISH => 1,
                RespCommand.SPUBLISH => 1,
                RespCommand.SELECT => 1,
                _ => -1
            };
        }

        private int SortedSetObjectKeys(SortedSetOperation command, int inputCount)
        {

            return command switch
            {
                SortedSetOperation.ZADD => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREM => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZCARD => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZPOPMAX => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZSCORE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZMSCORE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZCOUNT => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZINCRBY => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZRANGE => SingleKey(1, true, LockType.Shared),
                SortedSetOperation.ZREVRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYLEX => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYRANK => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZREMRANGEBYSCORE => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZLEXCOUNT => SingleKey(1, true, LockType.Exclusive),
                SortedSetOperation.ZPOPMIN => SingleKey(1, true, LockType.Exclusive),