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

Fix for Issue #327 - Purges MySql cache contents older than a configu #329

Merged
merged 4 commits into from
Mar 12, 2016

Conversation

ifsnop
Copy link
Contributor

@ifsnop ifsnop commented Nov 3, 2013

I have added a new option to the MySql cache backend. Configured through set_cache_location():
cache_purge_time=seconds. It defaults to 2592000 (30 days). Everything older (not updated for 30 days) will be deleted before each call to save(), that is, when storing/updating content from the cache.

$feed->set_cache_location('mysql://user:pass@localhost:3306/table?prefix=sp_&cache_purge_time=2592000');

The following sql code will be run before any update.

DELETE i, cd 
FROM `sp_cache_data` cd, `sp_items` i
WHERE cd.id = i.feed_id AND cd.mtime < (unix_timestamp() - cache_purge_time

@ifsnop
Copy link
Contributor Author

ifsnop commented Feb 11, 2014

I'd appreciate some feedback... :)

@mblaney
Copy link
Member

mblaney commented Feb 12, 2014

a few things, you don't use $count so there's no point assigning to it. Since you don't need the return value I think exec is better than query here? And you might actually be better of using a prepared statement and binding cache_purge_time.

@ifsnop
Copy link
Contributor Author

ifsnop commented Feb 12, 2014

You were totally right... binding is safer.

Logic remains the same to delete old cached data.

@mblaney mblaney merged commit 89fc162 into simplepie:master Mar 12, 2016
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

Successfully merging this pull request may close these issues.

2 participants