-
Notifications
You must be signed in to change notification settings - Fork 167
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
Getting last id #235
Comments
The last ID is stored as a separate Redis key at You could get the last ID with a Redis GET: Ohm.redis.call("GET", "User:id") |
Thanks for answer, it helps in my case. It seems like undocumented feature. |
Can you add feature request label? |
@katecanaveral I just added the label. Not sure if I prefer |
My case is using last user id for next id prediction, i use it in next username.
About method |
@katecanaveral regardless of the last id feature, I'd want to comment on a possible source of bugs with your approach. If timed just right, you might get an incorrect But also: it doesn't seem like you need to store the class User < Ohm::Model
def name
"user_#{ id }"
end
end Maybe there are extra considerations that make you actually need a |
Is there a method for last id getting?
Something like
User.last_id
, more low-cost (and low-level) than currentUser.all.ids[-1]
The text was updated successfully, but these errors were encountered: