Skip to content

Conversation

sgtsquiggs
Copy link

@sgtsquiggs sgtsquiggs commented Jun 11, 2025

This PR will make the reids:",ver" tag optional. This PR will resolve #854.

Usecase:

You are using rueidis/om to keep a cache up-to-date, reading directly off a kafka queue. You do not want to deal with versioning your data in redis. You are always upserting.

TODO:

  • Update README and documentation

Comment on lines +74 to +75
s.ver = &field{reflect.TypeOf(int64(0)), "", -1, false, true, false}
s.verless = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it is possible to just keep s.ver == nil?

Copy link
Author

Choose a reason for hiding this comment

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

Definitely can do that, just would result in more LOC changed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sgtsquiggs, maybe we should keep the current approach. Is this PR ready for merge?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @sgtsquiggs, could you help resolve the conflicts?

@SoulPancake
Copy link
Contributor

@sgtsquiggs Are you continuing on this?

@sgtsquiggs sgtsquiggs marked this pull request as ready for review October 19, 2025 22:47
Comment on lines +112 to +114
if r.schema.verless {
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

When will this happen? If it never happens, can we just delete it?

Suggested change
if r.schema.verless {
return nil
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

On the other hand, if the case does happen, we should not return nil either.

Copy link
Author

Choose a reason for hiding this comment

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

I modified the script (here) to return nil if the ver arg is not present. Alternatively I could have used another script that does not perform optimistic locking, and forked based on r.schema.verless.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, can we align with the original behavior to return ARGV[2] as well?

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely. Wrote this PR quickly so I could fork and use om - looking at this code today I don't remember a lot of it and it looks a little dodgy to me. I'll try to reimplement a bit cleaner this week.

Comment on lines +134 to +135
if r.schema.verless {
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. Can we delete this?

// ver is no longer required
if s.ver == nil {
panic(fmt.Sprintf("schema %q should have one field with `redis:\",ver\"` tag", t))
s.ver = &field{reflect.TypeOf(int64(0)), "", -1, false, true, false}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Field names should be explicitly specified.

@sgtsquiggs
Copy link
Author

Withdrawing this PR to rework it 👍

@sgtsquiggs sgtsquiggs marked this pull request as draft October 20, 2025 13:33
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.

Let us disable optimistic locking in github.com/redis/rueidis/om

3 participants