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

Cache search results #7

Open
doncadavona opened this issue Apr 21, 2024 · 0 comments
Open

Cache search results #7

doncadavona opened this issue Apr 21, 2024 · 0 comments

Comments

@doncadavona
Copy link
Owner

Cache search results.

I am thinking of sorting the characters of query string alphabetically to get a consistent arrangement of the query string.
That way, the search results are consistent regardless of the order of the query string parameters:

example.com/users?created_at=1999-12-31&birth_date=2001-01-31
example.com/users?birth_date=2001-01-31&created_at=1999-12-31

Notice that the above query string are not equal in ordering, but has equal parameters and values.

By sorting them alphabetically, we can confirm their equality:

&----0001111112233999==__aaabcddeeehirrtttt
&----0001111112233999==__aaabcddeeehirrtttt

We can then cache them as the sorted query string as the key and the result as the value.

Optionally, we may need to hash the key to get a consistent and small key length, as query strings lengths are inconsistent and may get very lengthy.

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

No branches or pull requests

1 participant