@@ -54,7 +54,7 @@ def test_get_last_ignore_deleted(
54
54
tx .set (timestamp = 9 , value = "value9-stored" , prefix = b"key" )
55
55
56
56
with transaction () as tx :
57
- tx .expire (timestamp = 9 , prefix = b"key" )
57
+ tx .expire (timestamp = 10 , prefix = b"key" )
58
58
59
59
# Message with timestamp 8 comes out of order after later messages
60
60
# got expired in the same transaction.
@@ -114,13 +114,35 @@ def test_get_last_prefix_not_bytes(transaction: TimestampedPartitionTransaction)
114
114
assert tx .get_last (timestamp = 10 , prefix = b'"key"' ) == "value"
115
115
116
116
117
+ def test_get_last_from_cache_with_retention (
118
+ transaction : TimestampedPartitionTransaction ,
119
+ ):
120
+ with transaction () as tx :
121
+ tx .set (timestamp = 5 , value = "value" , prefix = b"key" )
122
+ assert tx .get_last (timestamp = 10 , prefix = b"key" ) == "value"
123
+ assert tx .get_last (timestamp = 10 , prefix = b"key" , retention = 5 ) == "value"
124
+ assert tx .get_last (timestamp = 10 , prefix = b"key" , retention = 4 ) == None
125
+
126
+
127
+ def test_get_last_from_store_with_retention (
128
+ transaction : TimestampedPartitionTransaction ,
129
+ ):
130
+ with transaction () as tx :
131
+ tx .set (timestamp = 5 , value = "value" , prefix = b"key" )
132
+
133
+ with transaction () as tx :
134
+ assert tx .get_last (timestamp = 10 , prefix = b"key" ) == "value"
135
+ assert tx .get_last (timestamp = 10 , prefix = b"key" , retention = 5 ) == "value"
136
+ assert tx .get_last (timestamp = 10 , prefix = b"key" , retention = 4 ) == None
137
+
138
+
117
139
def test_expire_cached (transaction : TimestampedPartitionTransaction ):
118
140
with transaction () as tx :
119
141
tx .set (timestamp = 1 , value = "value1" , prefix = b"key" )
120
142
tx .set (timestamp = 10 , value = "value10" , prefix = b"key" )
121
143
tx .set (timestamp = 11 , value = "value11" , prefix = b"key" )
122
144
123
- tx .expire (timestamp = 10 , prefix = b"key" )
145
+ tx .expire (timestamp = 11 , prefix = b"key" )
124
146
125
147
assert tx .get_last (timestamp = 10 , prefix = b"key" ) == None
126
148
assert tx .get_last (timestamp = 11 , prefix = b"key" ) == "value11"
@@ -133,7 +155,7 @@ def test_expire_stored(transaction: TimestampedPartitionTransaction):
133
155
tx .set (timestamp = 11 , value = "value11" , prefix = b"key" )
134
156
135
157
with transaction () as tx :
136
- tx .expire (timestamp = 10 , prefix = b"key" )
158
+ tx .expire (timestamp = 11 , prefix = b"key" )
137
159
138
160
assert tx .get_last (timestamp = 10 , prefix = b"key" ) == None
139
161
assert tx .get_last (timestamp = 11 , prefix = b"key" ) == "value11"
@@ -146,7 +168,7 @@ def test_expire_idempotent(transaction: TimestampedPartitionTransaction):
146
168
with transaction () as tx :
147
169
tx .set (timestamp = 10 , value = "value10" , prefix = b"key" )
148
170
149
- tx .expire (timestamp = 10 , prefix = b"key" )
150
- tx .expire (timestamp = 10 , prefix = b"key" )
171
+ tx .expire (timestamp = 11 , prefix = b"key" )
172
+ tx .expire (timestamp = 11 , prefix = b"key" )
151
173
152
174
assert tx .get_last (timestamp = 10 , prefix = b"key" ) == None
0 commit comments