| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | # Copyright (c) 2009 AdCopy | ||
| 4 | # Author: Jeff Weisberg | ||
| 5 | # Created: 2009-Apr-13 11:55 (EDT) | ||
| 6 | # Function: auto-expire old data | ||
| 7 | # | ||
| 8 | # $Id$ | ||
| 9 | |||
| 10 | package AC::Yenta::Store::Expire; | ||
| 11 | use AC::Yenta::Config; | ||
| 12 | use AC::Yenta::Debug 'expire'; | ||
| 13 | use AC::Yenta::Conf; | ||
| 14 | use AC::DC::Sched; | ||
| 15 | use strict; | ||
| 16 | |||
| 17 | AC::DC::Sched->new( | ||
| 18 | info => 'expire', | ||
| 19 | freq => 60, | ||
| 20 | func => \&AC::Yenta::Store::Expire::periodic, | ||
| 21 | ); | ||
| 22 | |||
| 23 | sub periodic { | ||
| 24 | |||
| 25 | my $maps = conf_value('map'); | ||
| 26 | for my $map (keys %$maps){ | ||
| 27 | my $cf = conf_map($map); | ||
| 28 | next unless $cf->{expire}; | ||
| 29 | |||
| 30 | my $expire = timet_to_yenta_version($^T - $cf->{expire}); | ||
| 31 | debug("running expire from $expire"); | ||
| 32 | AC::Yenta::Store::store_expire( $map, $expire ); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | ################################################################ | ||
| 37 | |||
| 38 | |||
| 39 | 1; |