Commit 82d0ed9b authored by Leigh Stoller's avatar Leigh Stoller

Add common Flush() code, so that we can get all the caches in one call.

parent 129defe2
#!/usr/bin/perl -wT
#
# Copyright (c) 2012,2013 University of Utah and the Flux Group.
# Copyright (c) 2012,2013,2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -38,6 +38,7 @@ use overload ('""' => 'Stringify');
# Cache of instances to avoid regenerating them.
my %bstypes = ();
BEGIN { use emutil; emutil::AddCache(\%bstypes); }
my $debug = 0;
# Little helper and debug function.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2015 University of Utah and the Flux Group.
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -227,6 +227,7 @@ $EXPT_RESOURCESHOSED = 0;
# Cache of instances to avoid regenerating them.
%experiments = ();
BEGIN { use emutil; emutil::AddCache(\%experiments); }
# Little helper and debug function.
sub mysystem($)
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2015 University of Utah and the Flux Group.
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -54,6 +54,7 @@ my $MIN_UNIX_GID = @MIN_UNIX_GID@;
# Cache of instances to avoid regenerating them.
my %groups = ();
BEGIN { use emutil; emutil::AddCache(\%groups); }
my $debug = 0;
# MemberList flags.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2014 University of Utah and the Flux Group.
# Copyright (c) 2005-2014, 2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -44,6 +44,9 @@ my $BOSSNODE = "@BOSSNODE@";
# Cache of instances to avoid regenerating them.
my %all_interfaces = ();
my %node_interfaces = ();
BEGIN { use emutil;
emutil::AddCache(\%all_interfaces);
emutil::AddCache(\%node_interfaces); }
# Manual
my $debug = 0;
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2007-2015 University of Utah and the Flux Group.
# Copyright (c) 2007-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -52,6 +52,7 @@ my $TBOPS = "@TBOPSEMAIL@";
# Cache of instances to avoid regenerating them.
my %lans = ();
BEGIN { use emutil; emutil::AddCache(\%lans); }
my $debug = 0;
sub debugging() {return $debug; }
......@@ -1397,6 +1398,7 @@ use overload ('""' => 'Stringify');
# Cache of instances to avoid regenerating them.
my %members = ();
BEGIN { use emutil; emutil::AddCache(\%members); }
#
# Lookup and create a class instance to return.
......@@ -1671,6 +1673,7 @@ use overload ('""' => 'Stringify');
# Cache of instances to avoid regenerating them.
my %interfaces = ();
BEGIN { use emutil; emutil::AddCache(\%interfaces); }
# accessors
sub field($$) { return ((! ref($_[0])) ? -1 : $_[0]->{'IFACE'}->{$_[1]}); }
......@@ -2438,6 +2441,7 @@ my $SNMPIT = "$TB/bin/snmpit";
# Cache of instances to avoid regenerating them.
my %vlans = ();
BEGIN { use emutil; emutil::AddCache(\%vlans); }
#
# Lookup and create a class instance to return.
......@@ -3746,6 +3750,7 @@ use overload ('""' => 'Stringify');
# Cache of instances to avoid regenerating them.
my %tunnels = ();
BEGIN { use emutil; emutil::AddCache(\%tunnels); }
#
# Lookup and create a class instance to return.
......
......@@ -64,6 +64,7 @@ $NODEROLE_TESTNODE = 'testnode';
# Cache of instances to avoid regenerating them.
%nodes = ();
BEGIN { use emutil; emutil::AddCache(\%nodes); }
# Little helper and debug function.
sub mysystem($)
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2014 University of Utah and the Flux Group.
# Copyright (c) 2005-2014, 2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -43,6 +43,10 @@ my $BOSSNODE = "@BOSSNODE@";
# Cache of instances to avoid regenerating them.
my %nodetypes = ();
my %nodeclasses = ();
BEGIN { use emutil;
emutil::AddCache(\%nodetypes);
emutil::AddCache(\%nodeclasses); }
my $debug = 0;
# Little helper and debug function.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2015 University of Utah and the Flux Group.
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -55,6 +55,8 @@ my $ADDPROJADMINLIST = "$TB/sbin/addprojadminlist";
# Cache of instances to avoid regenerating them.
my %projects = ();
BEGIN { use emutil; emutil::AddCache(\%projects); }
my $debug = 0;
# Little helper and debug function.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2012-2015 University of Utah and the Flux Group.
# Copyright (c) 2012-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -47,6 +47,7 @@ my $UNLIMITED = -1;
# cache of instances to avoid regenerating them.
my %quotas = ();
BEGIN { use emutil; emutil::AddCache(\%quotas); }
my $debug = 0;
# Little helper and debug function.
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2015 University of Utah and the Flux Group.
# Copyright (c) 2005-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -387,6 +387,22 @@ sub LookupNonLocal($$)
return User->Lookup($uid_idx);
}
#
# Flush from our little cache.
#
sub Flush($)
{
my ($self) = @_;
delete($users{$self->uid_idx()});
}
sub FlushAll($)
{
my ($class) = @_;
%users = ();
}
#
# Class function to create new user and return object.
#
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2009-2014 University of Utah and the Flux Group.
# Copyright (c) 2009-2014, 2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -64,6 +64,7 @@ my $TBOPS = "@TBOPSEMAIL@";
# Cache of instances to avoid regenerating them.
my %virtexperiments = ();
BEGIN { use emutil; emutil::AddCache(\%virtexperiments); }
my $debug = 0;
#
......
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -45,6 +45,24 @@ use Time::Local;
# Configure variables.
my $TB = "@prefix@";
#
# Store up the list of caches to flush
#
my @ourcaches = ();
sub AddCache($)
{
my ($ref) = @_;
push(@ourcaches, $ref);
}
sub FlushCaches()
{
foreach my $ref (@ourcaches) {
%$ref = ();
}
}
#
# Support for checking field values against what is specified.
#
......@@ -883,5 +901,6 @@ sub waitForMount($;$)
return -1;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment