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

Purging a key automatically appends an ending wildcard? #596

Open
teodorescuserban opened this issue Jan 22, 2025 · 1 comment
Open

Purging a key automatically appends an ending wildcard? #596

teodorescuserban opened this issue Jan 22, 2025 · 1 comment

Comments

@teodorescuserban
Copy link

Hello, I am using souin cache as caddy module.

/etc/caddy # caddy version
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
/etc/caddy # caddy build-info | grep souin
dep     github.com/darkweak/souin       v1.7.5  h1:drNhZc0GhSbGcugiGfcYdLDTcx3DCZW6o13wwRj5o5Y=
/etc/caddy # caddy build-info | grep stora
dep     github.com/darkweak/storages/core       v0.0.11 h1:IwvpAtkhOmxC5pIffJ8opW6erpTnIi5zqPveiAQs8ew=
dep     github.com/darkweak/storages/go-redis   v0.0.11 h1:2IjIEPREWyooSAq4syKeFq/yeia5sPnaypzs/GK3tRo=
dep     github.com/darkweak/storages/go-redis/caddy     v0.0.11 h1:d6qQRAzOJLSmQkLXEW/XVTAkh/C0kofPP3LxoP9djWs=

My cache key template is template {http.request.uri}.

I noticed while testing purging by accident while providing a partial key. To my surprise, even though I did not put the * at the end, all keys matching that prefix have been removed from cache.

Example:

$ curl -X GET localhost/souin-api/souin/
/v3/viewLog?day=1
/v3/viewLog?day=2
/v3/viewLog?day=3
/v3/viewLog?day=4
/v3/view1d?axis=x

If I try to purge a partial key, all keys [matching the prefix] are being removed:

$ curl -X PURGE localhost/souin-api/souin/v3/viewL
$ curl -X GET localhost/souin-api/souin/
/v3/view1d?axis=x

What I am missing?

Thank you!

@darkweak
Copy link
Owner

darkweak commented Jan 22, 2025

@teodorescuserban it interprets the key as regex so you have to set a trailing $ to restrict to the given key.

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

2 participants