Skip to content

Conversation

@factyy
Copy link
Contributor

@factyy factyy commented Jul 29, 2025

The original cache implementation relies on two main parts: scope and query.

Quite often we use scoping as a policy-based access control for listing actions like index. With Graphiti it is easily achieved by making #base_scope context-aware (e.g. like checking a requesting user role and restricting access to certain entities for non-admins). The problem is that it is only represented via changes in the DB query object (we have different cache keys for different scopes since they result in different queries). One of the side effects is that Graphiti has no idea about it and cache debugger stubbornly states lots and lots of cache misses (it associates cache keys with the request info that doesn't include any info from the request context).

The idea behind this PR is simple: enable cache tagging with a value returned from a resource instance method (that can access request context). This method name has to be passed as a symbol argument to the cache_resource resource class method alongside expires_in argument.

@superslau
Copy link
Contributor

I have a very similar issue, so interested to see what is necessary for this to get merged.

@factyy
Copy link
Contributor Author

factyy commented Oct 1, 2025

@jkeen , sorry to bother, is there anything I can help you with to merge this PR?

@jkeen
Copy link
Collaborator

jkeen commented Jan 2, 2026

@factyy Sorry for the delay, I think this is good? I'm not sure why that one test is failing though, and it looks like I left this sit for too long and I can't seem to re-run it on CI to make sure it's just an intermittent thing

@factyy
Copy link
Contributor Author

factyy commented Jan 6, 2026

@jkeen , probably it is still good, as far as I remember there weren't any breaking changes...

@jkeen jkeen merged commit e8c2bad into graphiti-api:main Jan 6, 2026
46 of 47 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 6, 2026
# [1.10.0](v1.9.0...v1.10.0) (2026-01-06)

### Features

* add cache tag support to allow context-aware caching ([#498](#498)) ([e8c2bad](e8c2bad))
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

🎉 This PR is included in version 1.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants