invidious icon indicating copy to clipboard operation
invidious copied to clipboard

Use Redis for caching

Open SamantazFox opened this issue 2 years ago • 9 comments

Closes #3628

SamantazFox avatar May 21 '23 21:05 SamantazFox

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

github-actions[bot] avatar Jul 30 '23 01:07 github-actions[bot]

What do you think about splitting the video cache into two? One for the streaming urls and the other for the metadata. We'd be able to persist the metadata for a lot longer than 6 hours then.

syeopite avatar Aug 27 '23 00:08 syeopite

What do you think about splitting the video cache into two? One for the streaming urls and the other for the metadata. We'd be able to persist the metadata for a lot longer than 6 hours then.

That could be doable, I think. I guess you want the metadata to be used for imports or playlists?

SamantazFox avatar Aug 28 '23 22:08 SamantazFox

I guess you want the metadata to be used for imports or playlists?

Yep. From what I can see Invidious also often calls #get_video to fetch video metadata only so splitting the cache can probably also save us quite a few calls to YouTube.

syeopite avatar Aug 29 '23 06:08 syeopite

In the end, I think I'll go with that separation:

videos:<id>:title

  • Stores: the video title
  • Format: raw text
  • Retention: as long as possible (2 months?)

videos:<id>:release_date

  • Stores: the exact date at which the video was released
  • Format: ISO date
  • Retention: as long as possible (1 year?)
  • Updated from: watch page or channel RSS feed

videos:<id>:playback

  • Stores: the video's playback infos (captions/storyboards/streams)
  • Format: JSON
  • Retention: 5h, to keep the links fresh, except for livestreams where this is reduced to 1h.

videos:<id>:metadata

  • Stores: all the miscellaneous metadata for the watch page
  • Format: JSON
  • Retention: a few hours if the video was released recently, to keep views, likes and description fresh. After that, keep for a day or two.

SamantazFox avatar Oct 23 '23 22:10 SamantazFox

Titles should probably just be included as a part of metadata imo. It's something that changes fairly frequently (especially when the video is new) and in some cases frequent title changes are the entire point of the video such as this one https://redirect.invidious.io/watch?v=BxV14h0kFs0

As for playback, you can probably split off storyboards from it. It's not something that should change often if at all.

syeopite avatar Oct 24 '23 07:10 syeopite

Titles should probably just be included as a part of metadata imo. It's something that changes fairly frequently (especially when the video is new) and in some cases frequent title changes are the entire point of the video such as this one https://redirect.invidious.io/watch?v=BxV14h0kFs0

I know that titles may change (especially true when the video was recently released, to boost views). The main goal is to address #1356 and/or #3959 + #3035, which requires a long cache time.

As for playback, you can probably split off storyboards from it. It's not something that should change often if at all.

So you'd wand it with the metadata? Or separated? In all cases, all data will be refreshed whenever the video needs to be played.

SamantazFox avatar Oct 25 '23 18:10 SamantazFox

So you'd wand it with the metadata? Or separated?

Either or is fine. I'm just not entirely sure why captions and storyboards are placed under videos:<id>:playback

syeopite avatar Oct 25 '23 22:10 syeopite

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

github-actions[bot] avatar May 14 '24 01:05 github-actions[bot]