Skip to content

Commit 8a70e1f

Browse files
committed
Rename retention to retention_ms
1 parent 156723c commit 8a70e1f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

quixstreams/state/rocksdb/timestamped.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_last(
4242
self,
4343
timestamp: int,
4444
prefix: Any,
45-
retention: int = DAYS_7,
45+
retention_ms: int = DAYS_7,
4646
cf_name: str = "default",
4747
) -> Optional[Any]:
4848
"""Get the latest value for a prefix up to a given timestamp.
@@ -56,7 +56,7 @@ def get_last(
5656
5757
:param timestamp: The upper bound timestamp (inclusive) in milliseconds.
5858
:param prefix: The key prefix.
59-
:param retention: The retention period in milliseconds.
59+
:param retention_ms: The retention period in milliseconds.
6060
:param cf_name: The column family name.
6161
:return: The deserialized value if found, otherwise None.
6262
"""
@@ -65,7 +65,7 @@ def get_last(
6565
prefix = self._ensure_bytes(prefix)
6666

6767
# Negative retention is not allowed
68-
lower_bound_timestamp = max(timestamp - retention, 0)
68+
lower_bound_timestamp = max(timestamp - retention_ms, 0)
6969
lower_bound = self._serialize_key(lower_bound_timestamp, prefix)
7070
# +1 because upper bound is exclusive
7171
upper_bound = self._serialize_key(timestamp + 1, prefix)

tests/test_quixstreams/test_state/test_rocksdb/test_timestamped.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def test_get_last_from_cache_with_retention(
117117
with transaction() as tx:
118118
tx.set(timestamp=5, value="value", prefix=b"key")
119119
assert tx.get_last(timestamp=10, prefix=b"key") == "value"
120-
assert tx.get_last(timestamp=10, prefix=b"key", retention=5) == "value"
121-
assert tx.get_last(timestamp=10, prefix=b"key", retention=4) == None
120+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=5) == "value"
121+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=4) == None
122122

123123

124124
def test_get_last_from_store_with_retention(
@@ -129,8 +129,8 @@ def test_get_last_from_store_with_retention(
129129

130130
with transaction() as tx:
131131
assert tx.get_last(timestamp=10, prefix=b"key") == "value"
132-
assert tx.get_last(timestamp=10, prefix=b"key", retention=5) == "value"
133-
assert tx.get_last(timestamp=10, prefix=b"key", retention=4) == None
132+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=5) == "value"
133+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=4) == None
134134

135135

136136
@mock.patch("quixstreams.state.rocksdb.timestamped.EXPIRATION_COUNTER", 1000)
@@ -146,7 +146,7 @@ def test_get_last_from_cache_with_expire_call(
146146
# Expiration counter is exhausted for this `get_last` call
147147
# `_expire` method is called with `lower_bound_timestamp` = 10 - 4 = 6
148148
# Everything below timestamp 6 gets expired.
149-
assert tx.get_last(timestamp=10, prefix=b"key", retention=4) == None
149+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=4) == None
150150
assert tx._update_cache.get_updates_for_prefix(prefix=b"key") == {}
151151

152152

@@ -166,7 +166,7 @@ def test_get_last_from_store_with_expire_call(
166166
# Expiration counter is exhausted for this `get_last` call
167167
# `_expire` method is called with `lower_bound_timestamp` = 10 - 4 = 6
168168
# Everything belowe timestamp 6 gets expired.
169-
assert tx.get_last(timestamp=10, prefix=b"key", retention=4) == None
169+
assert tx.get_last(timestamp=10, prefix=b"key", retention_ms=4) == None
170170
assert key in tx._update_cache.get_deletes()
171171

172172
with transaction() as tx:

0 commit comments

Comments
 (0)