Skip to content

Instantly share code, notes, and snippets.

@DavidWittman
Last active December 14, 2015 09:08
Show Gist options
  • Save DavidWittman/5062343 to your computer and use it in GitHub Desktop.
Save DavidWittman/5062343 to your computer and use it in GitHub Desktop.
MySQL scheduled event to remove Keystone authentication tokens expired for over one week.
USE keystone
-- This needs to be set in the my.cnf to persist
SET GLOBAL event_scheduler = 1;
DELIMITER $$
CREATE EVENT tokenreaper
ON SCHEDULE EVERY 1 WEEK
DO BEGIN
DELETE FROM `token` WHERE expires <= DATE_SUB(NOW(), INTERVAL 1 WEEK);
END $$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment