Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

WP_PJAX_PageCache::clearCache implemenation is bugos #8

Open
eimanavicius opened this issue Mar 31, 2016 · 4 comments
Open

WP_PJAX_PageCache::clearCache implemenation is bugos #8

eimanavicius opened this issue Mar 31, 2016 · 4 comments

Comments

@eimanavicius
Copy link
Contributor

$wpdb->query( "DELETE FROM ". $wpdb->prefix ."options WHERE option_name LIKE ('_transient_".WP_PJAX_TRANIENT_PREFIX."%')" );

phpcs: WordPress.VIP.DirectDatabaseQuery: Usage of a direct database call is discouraged.

Deleting "transient%" options from database does not mean cache cleared. Other back-end can be used (ex. memcache, redis).
Cache versions can be used to invalidate cache. Version would be stored in cache and changed when clearing cache.

@pelmered
Copy link
Owner

pelmered commented Apr 1, 2016

Good point. The only way to do this must be to make a select query to get all the transient keys and then loop through them and then run delete_transient() on each one. Not very pretty, but that would allow any backend to handle this.

Or do you have any suggestions/ideas?

The page cache functionality nerver really worked very good, and should probably get a rewrite as well.

@eimanavicius
Copy link
Contributor Author

Well selecting all key would not help as database is not the only possible cache back-end.

My suggestion would be:

Cache version can be used to invalidate cache. Version would be stored in cache and changed when clearing cache.

This technique is used in Doctrine 2 ORM caching solution.

@pelmered
Copy link
Owner

pelmered commented Apr 1, 2016

You mean something like generating keys like prefix_<version (generated random string)>_<key> and then generate a new version string when you clear the cache? For example: wp_pjax_pc-876b438o-test-page
That would be a good solution.

@eimanavicius
Copy link
Contributor Author

Yes, exactly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants