purgeLocalCache 1.58 KB
Newer Older
1 2
#!/usr/bin/perl
#=============================================================================
3
# Cleaner for LemonLDAP::NG: purge local handler cache and session cache
4
#
5
# This module is written to be used by cron to clean cache objects used
6
# by Handler.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#
# This is part of LemonLDAP::NG product, released under GPL
#=============================================================================

use Lemonldap::NG::Common::Conf;
use Lemonldap::NG::Common::Conf::Constants;
use strict;

my $debug = 0;

#=============================================================================
# Load configuration
#=============================================================================
my $lmconf = Lemonldap::NG::Common::Conf->new()
  or die $Lemonldap::NG::Common::Conf::msg;
22 23
my $conf = $lmconf->getConf or die "Unable to get configuration ($!)";
my $localconf = $lmconf->getLocalConf(HANDLERSECTION)
24 25
  or die "Unable to get local configuration ($!)";

26 27 28 29
if ($localconf) {
    $conf->{$_} = $localconf->{$_} foreach ( keys %$localconf );
}

30
print "Configuration loaded\n" if $debug;
31 32

# Handler cache
33 34 35 36 37 38
if ( $conf->{localStorage} ) {
    eval "require $conf->{localStorage}";
    $conf->{localStorageOptions}->{default_expires_in} ||= 600;
    my $c = $conf->{localStorage}->new( $conf->{localStorageOptions} );
    $c->purge();
}
39

40
# Session cache
41 42 43 44 45 46 47
if ( $conf->{localSessionStorage} ) {
    eval "require $conf->{localSessionStorage}";
    $conf->{localSessionStorageOptions}->{default_expires_in} ||= 600;
    my $s =
      $conf->{localSessionStorage}->new( $conf->{localSessionStorageOptions} );
    $s->purge();
}
48

49
exit 0;