@@ -148,3 +148,33 @@ def test_set_for_timestamp_with_retention_stored(
148
148
with transaction () as tx :
149
149
assert tx .get_last (timestamp = 2 , prefix = b"key" ) == None
150
150
assert tx .get_last (timestamp = 5 , prefix = b"key" ) == "v5"
151
+
152
+
153
+ def test_expire_multiple_keys (transaction : TimestampedPartitionTransaction ):
154
+ with transaction () as tx :
155
+ tx .set_for_timestamp (timestamp = 1 , value = "11" , prefix = b"key1" , retention_ms = 10 )
156
+ tx .set_for_timestamp (timestamp = 1 , value = "21" , prefix = b"key2" , retention_ms = 10 )
157
+ tx .set_for_timestamp (timestamp = 12 , value = "112" , prefix = b"key1" , retention_ms = 10 )
158
+ tx .set_for_timestamp (timestamp = 12 , value = "212" , prefix = b"key2" , retention_ms = 10 )
159
+
160
+ with transaction () as tx :
161
+ assert tx .get (key = 1 , prefix = b"key1" ) is None
162
+ assert tx .get (key = 1 , prefix = b"key2" ) is None
163
+ assert tx .get (key = 12 , prefix = b"key1" ) == "112"
164
+ assert tx .get (key = 12 , prefix = b"key2" ) == "212"
165
+
166
+ # Expiration advances only on `set_for_timestamp` calls
167
+ assert tx .get_last (timestamp = 30 , prefix = b"key1" ) == "112"
168
+ assert tx .get_last (timestamp = 30 , prefix = b"key2" ) == "212"
169
+
170
+
171
+ def test_set_for_timestamp_overwrites_value_with_same_timestamp (
172
+ transaction : TimestampedPartitionTransaction ,
173
+ ):
174
+ with transaction () as tx :
175
+ tx .set_for_timestamp (timestamp = 1 , value = "11" , prefix = b"key" )
176
+ tx .set_for_timestamp (timestamp = 1 , value = "21" , prefix = b"key" )
177
+ assert tx .get_last (timestamp = 1 , prefix = b"key" ) == "21"
178
+
179
+ with transaction () as tx :
180
+ assert tx .get_last (timestamp = 1 , prefix = b"key" ) == "21"
0 commit comments