valu-digital / wp-graphql-cache

Flexible caching framework for WPGraphQL
GNU General Public License v2.0
41 stars 9 forks source link

Multisite support #3

Open AbeCole opened 4 years ago

AbeCole commented 4 years ago

Thanks for making this plugin I know it's early alpha but should help me massively in my current project.

Was looking to use this would 'multisite' Wordpress setup, by default that wasn't working as it was returning content for the incorrect site (since that content was already cached). I think the issue is the query key set in src/QueryCache.php, line 79:

$this->key = "query-{$this->query_name}-${user_id}-{$query_hash}-${args_hash}";

By default this ignores the current 'site' in the multisite setup, I've addressed this by modifying it to:

$blog_id = get_current_blog_id();
$this->key = "query-{$blog_id}-{$this->query_name}-${user_id}-{$query_hash}-${args_hash}";

In a bit of a rush at moment so just leaving this issue here as a 'note' and will try to find time to make a proper pull request for this change.