Skip to content

Conversation

@draelos
Copy link
Collaborator

@draelos draelos commented May 27, 2025

Adding expiration of data during a put operation; results in much lower memory usage and much faster overall execution, in our use cases.

@draelos draelos requested a review from jmxpearson May 27, 2025 15:46
@coveralls
Copy link
Collaborator

coveralls commented May 27, 2025

Pull Request Test Coverage Report for Build 19915251842

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on dev at 75.06%

Totals Coverage Status
Change from base Build 19467394522: 75.1%
Covered Lines: 1562
Relevant Lines: 2081

💛 - Coveralls

Copy link
Contributor

@jmxpearson jmxpearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. I have a couple of questions in the review, and one line still needs to be reformatted to pass black checks.

Args:
object: the object to store in Redis
object_key (str): the key under which the object should be stored
ex (int): TTL; the number of seconds after which the object got expired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English phrasing: Maybe something like

ex (int): time to live; number of seconds until object will expire

improv/store.py Outdated

self.client.set(object_key, pickle.dumps(object, protocol=5), nx=True)
self.client.set(
object_key, pickle.dumps(object, protocol=5), nx=True, ex=ex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is nx here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nx = True means the key will only be set if it does not already exist in the redis store. If the key already exists, set() will be skipped.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah we should probably decide if we want default behavior to be non-overwriting or overwriting. The keys should never conflict but in the very very unlikely case they do. I think perhaps overwriting is more real-time... @jmxpearson ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the one hand, overwriting by default is begging for silent failure. On the other, speed is necessary.

In all, I’d probably prefer not overwriting as the default but exposing the option and documenting u der some section detailing optimizations (TTL, store size, etc.)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulawucu Let's keep nx=True then, but have it log if set is skipped? Is that possible with Redis code? Does it return any warnings?
Could also regen a key if set is going to be skipped.

Let's also file an issue to add any error handling for if there is key collision and the user is choosing nx=False.

self.data[self.frame_num], str(f"Gen_raw: {self.frame_num}")
)
else:
data_id = self.client.put(self.data[self.frame_num], ex=40)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only line we're changing relative to the other generator? Could we not inherit and overload the one method? Just seems like a lot of code duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants