Examples
Input: []
Expected Output: []
Explanation: No queries means no outputs.
Input: [["SET", "A", "x", "5", "u1"], ["GET", "A", "x"], ["GET", "A", "y"], ["DELETE", "A", "y", "u1"], ["DELETE", "A", "x", "u1"], ["GET", "A", "x"]]
Expected Output: ["OK", "5", "", "false", "true", ""]
Explanation: Basic create, read, delete-missing-field, delete-existing-field, and reading after the record is removed.
Input: [["SET", "A", "x", "1", "u1"], ["LOCK", "A", "u1"], ["SET", "A", "x", "2", "u2"], ["GET", "A", "x"], ["LOCK", "A", "u1"], ["LOCK", "A", "u2"], ["UNLOCK", "A", "u2"], ["UNLOCK", "A", "u1"], ["SET", "A", "x", "2", "u2"], ["GET", "A", "x"]]
Expected Output: ["OK", "ACQUIRED", "LOCKED", "1", "ACQUIRED", "WAIT", "INVALID", "RELEASED", "OK", "2"]
Explanation: A different user cannot write to a locked record, but reads still work. Lock and unlock are also checked for idempotence and ownership.
Input: [["SET", "R", "f", "v", "u1"], ["LOCK", "R", "u1"], ["DELETE", "R", "f", "u1"], ["GET", "R", "f"], ["UNLOCK", "R", "u1"], ["LOCK", "R", "u1"], ["SET", "R", "g", "w", "u2"], ["GET", "R", "g"]]
Expected Output: ["OK", "ACQUIRED", "true", "", "INVALID", "INVALID", "OK", "w"]
Explanation: Deleting the last field removes the whole record and its lock. After that, lock and unlock on that key are invalid until the record is created again.
Input: [["GET", "X", "a"], ["LOCK", "X", "u1"], ["UNLOCK", "X", "u1"], ["DELETE", "X", "a", "u1"]]
Expected Output: ["", "INVALID", "INVALID", "false"]
Explanation: Operations on a non-existent record return empty string for GET, INVALID for LOCK/UNLOCK, and false for DELETE.
Input: [["SET", "B", "p", "7", "u1"], ["LOCK", "B", "u1"], ["SET", "B", "q", "8", "u1"], ["DELETE", "B", "z", "u1"], ["SET", "B", "p", "9", "u2"], ["DELETE", "B", "q", "u2"], ["GET", "B", "p"], ["GET", "B", "q"]]
Expected Output: ["OK", "ACQUIRED", "OK", "false", "LOCKED", "LOCKED", "7", "8"]
Explanation: The lock owner may continue writing and deleting, while other users are blocked from modifications.
Input: [["SET", "C", "a", "1", "u1"], ["UNLOCK", "C", "u2"], ["LOCK", "C", "u2"], ["UNLOCK", "C", "u2"]]
Expected Output: ["OK", "RELEASED", "ACQUIRED", "RELEASED"]
Explanation: Unlocking an already-unlocked existing record is idempotent and returns RELEASED regardless of userId.