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

enhancement: Fast Find for non-searchable Models #5

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

iksaku
Copy link
Contributor

@iksaku iksaku commented Oct 9, 2024

SCAN is a resource intensive and slow operation and, currently, it is the best way to implement Model searching.

However, not all Models are searchable, and when dealing with non-searchable models, we could skip the unnecessary SCAN and try to retrieve the model attributes using HGETALL directly, reducing the load on our Redis server(s).

@stevebauman
Copy link
Member

Awesome! Thanks for another PR @iksaku, really appreciate it 🙏

I've adjusted the logic a tiny bit. I think a model instance should always be returned if the hash exists instead of only returning if it has attributes. A developer may create a model with timestamps disabled and no attributes leading to an empty model, and this would lead to the find method returning null.

@stevebauman stevebauman merged commit 4b9a528 into DirectoryTree:master Oct 10, 2024
14 checks passed
@stevebauman
Copy link
Member

v1.4.2 has been released with this patch 👍

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