change dbCacheTimeout to groupCacheTimeout

This commit is contained in:
Colin Kuskie 2006-04-13 22:26:11 +00:00
parent ab4e801bfe
commit 4f60281392
6 changed files with 27 additions and 16 deletions

View file

@ -90,7 +90,7 @@ sub _create {
deleteOffset=>14,
expireNotify=>0,
databaseLinkId=>0,
dbCacheTimeout=>3600,
groupCacheTimeout=>3600,
lastUpdated=>$self->session->datetime->time()
}, $override);
$self->addGroups([3]);
@ -686,6 +686,9 @@ sub getUsers {
my $withoutExpired = shift;
my $loopCount = shift;
my $expireTime = 0;
my $cache = WebGUI::Cache->new($self->session, $self->getId);
my $value = $cache->get;
return $value if defined $value;
if ($withoutExpired) {
$expireTime = $self->session->datetime->time();
}
@ -710,6 +713,7 @@ sub getUsers {
}
my %users = map { $_ => 1 } @users;
@users = keys %users;
$cache->set(\@users, $self->groupCacheTimeout);
return \@users;
}
@ -961,23 +965,23 @@ sub databaseLinkId {
#-------------------------------------------------------------------
=head2 dbCacheTimeout ( [ value ] )
=head2 groupCacheTimeout ( [ value ] )
Returns the dbCacheTimeout for this group.
Returns the groupCacheTimeout for this group.
=head3 value
If specified, the dbCacheTimeout is set to this value.
If specified, the groupCacheTimeout is set to this value.
=cut
sub dbCacheTimeout {
sub groupCacheTimeout {
my $self = shift;
my $value = shift;
if (defined $value) {
$self->set("dbCacheTimeout",$value);
$self->set("groupCacheTimeout",$value);
}
return $self->get("dbCacheTimeout");
return $self->get("groupCacheTimeout");
}
#-------------------------------------------------------------------

View file

@ -397,10 +397,10 @@ sub www_editGroup {
-value=>$g->ldapRecursiveProperty
);
$f->interval(
-name=>"dbCacheTimeout",
-name=>"groupCacheTimeout",
-label=>$i18n->get(1004),
-hoverHelp=>$i18n->get('1004 description'),
-value=>$g->dbCacheTimeout
-value=>$g->groupCacheTimeout
);
$f->submit;
$output .= $f->print;
@ -426,7 +426,7 @@ sub www_editGroupSave {
$g->autoDelete($session->form->yesNo("autoDelete"));
$g->databaseLinkId($session->form->process("databaseLinkId"));
$g->dbQuery($session->form->process("dbQuery"));
$g->dbCacheTimeout($session->form->interval("dbCacheTimeout"));
$g->groupCacheTimeout($session->form->interval("groupCacheTimeout"));
$g->ldapGroup($session->form->text("ldapGroup"));
$g->ldapGroupProperty($session->form->text("ldapGroupProperty"));
$g->ldapRecursiveProperty($session->form->text("ldapRecursiveProperty"));

View file

@ -298,13 +298,13 @@ sub isInGroup {
}
if(isIn($connectDn,@peeps)) {
$isInGroup->{$uid}{$gid} = 1;
if ($group->{'dbCacheTimeout'} > 10) {
if ($group->{'groupCacheTimeout'} > 10) {
$group->deleteUsers([$uid]);
$group->addUsers([$uid],$group->get("dbCacheTimeout"));
$group->addUsers([$uid],$group->get("groupCacheTimeout"));
}
} else {
$isInGroup->{$uid}{$gid} = 0;
$group->deleteUsers([$uid]) if ($group->get("dbCacheTimeout") > 10);
$group->deleteUsers([$uid]) if ($group->get("groupCacheTimeout") > 10);
}
$ldapLink->unbind;
$self->session->stow->set("isInGroup",$isInGroup);

View file

@ -86,9 +86,9 @@ sub execute {
});
}
}
my $sth = $self->session->db->read("select groupId,deleteOffset,dbCacheTimeout from groups");
my $sth = $self->session->db->read("select groupId,deleteOffset,groupCacheTimeout from groups");
while (my $data = $sth->hashRef) {
if ($data->{dbCacheTimeout} > 0) {
if ($data->{groupCacheTimeout} > 0) {
# there is no need to wait deleteOffset days for expired external group cache data
$self->session->db->write("delete from groupings where groupId=? and expireDate < ?", [$data->{groupId}, time()]);
} else {

View file

@ -1525,7 +1525,7 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
},
'1004' => {
message => q|Cache external groups for how long?|,
message => q|Cache groups for how long?|,
lastUpdated => 1057208065
},