Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream token optimization for media object IIIF manifest endpoint #5478

Merged
merged 3 commits into from
Nov 21, 2023

Conversation

cjcolvar
Copy link
Member

Resolves #5476

There are two StreamToken methods at the heart of this PR:

  • #purge_expired!
  • #get_stream_tokens_for

In purge_expired! the first loop is avoided by using delete_all. The second loop is avoided by inverting the logic: finding the existing tokens in the DB instead of removing ones that no longer exist.

get_stream_tokens_for is a new batch alternative to find_or_create_session_token. This new method uses upsert_all to update existing records and create ones that do not exist yet. It takes a little bit of special handling to create the array of attribute hashes that upsert requires. Ids need to be added to that hash in order for upsert to find existing records without a unique index in the DB.

The rest of the PR is refactoring to utilize get_stream_tokens_for.

Future Work:

cjcolvar and others added 3 commits November 20, 2023 11:04
@cjcolvar cjcolvar marked this pull request as ready for review November 21, 2023 19:10
Copy link
Contributor

@Dananji Dananji left a comment

Choose a reason for hiding this comment

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

Looks good to me as far as I understand 👍

@cjcolvar cjcolvar merged commit ca5b3e6 into develop Nov 21, 2023
@cjcolvar cjcolvar deleted the stream_token_optimized branch November 21, 2023 19:48
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.

2 participants