Record Store
Asked at Meta
Reported by the problem's creator, not verified
Build an in-memory record store as a class RecordStore. A record is addressed by a key and holds named fields, each holding a string value. Every test creates one RecordStore() and runs a sequence of calls, checking every return value; methods that return nothing are checked as None. A test only calls methods introduced so far.
Examples
Example 1
Input: init =
[], operations =[["set",["u1","name","ann"]],["get",["u1","name"]],["get",["u1","age"]],["get",["u2","name"]],["set",["u1","name","bob"]],["get",["u1","name"]],["delete",["u1","age"]],["delete",["u1","name"]],["get",["u1","name"]]]Output:
[null,"ann",null,null,null,"bob",false,true,null]Explanation:
getof an unset field or an unknown key returnsNone. The secondsetreplacesannwithbob. DeletingagereturnsFalsebecause it was never set; deletingnamereturnsTrue, after whichgetreturnsNone.