projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reduce the length of data in sentences to a default of 180 characters
[spider.git]
/
perl
/
DXUser.pm
diff --git
a/perl/DXUser.pm
b/perl/DXUser.pm
index 294a76c07774290b19bbea1a4141d6479bd0ee78..f31b79e6da0ee167b0bd83e9de92d73ccbad73ea 100644
(file)
--- a/
perl/DXUser.pm
+++ b/
perl/DXUser.pm
@@
-15,22
+15,24
@@
use Fcntl;
use IO::File;
use DXDebug;
use DXUtil;
use IO::File;
use DXDebug;
use DXUtil;
+use LRU;
use strict;
use vars qw($VERSION $BRANCH);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
use strict;
use vars qw($VERSION $BRANCH);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/
) || 0
;
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/
|| (0,0))
;
$main::build += $VERSION;
$main::branch += $BRANCH;
$main::build += $VERSION;
$main::branch += $BRANCH;
-use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime);
+use vars qw(%u $dbm $filename %valid $lastoperinterval $lasttime
$lru $lrusize
);
%u = ();
$dbm = undef;
$filename = undef;
$lastoperinterval = 60*24*60*60;
$lasttime = 0;
%u = ();
$dbm = undef;
$filename = undef;
$lastoperinterval = 60*24*60*60;
$lasttime = 0;
+$lrusize = 2000;
# hash of valid elements and a simple prompt
%valid = (
# hash of valid elements and a simple prompt
%valid = (
@@
-76,6
+78,8
@@
$lasttime = 0;
wantann_talk => '0,Talklike Anns,yesno',
wantpc90 => '1,Req PC90,yesno',
wantnp => '1,Req New Protocol,yesno',
wantann_talk => '0,Talklike Anns,yesno',
wantpc90 => '1,Req PC90,yesno',
wantnp => '1,Req New Protocol,yesno',
+ wantusers => '9,Want Users from node,yesno',
+ wantsendusers => '9,Send users to node,yesno',
lastoper => '9,Last for/oper,cldatetime',
nothere => '0,Not Here Text',
registered => '9,Registered?,yesno',
lastoper => '9,Last for/oper,cldatetime',
nothere => '0,Not Here Text',
registered => '9,Registered?,yesno',
@@
-84,26
+88,29
@@
$lasttime = 0;
build => '1,Build',
);
build => '1,Build',
);
-no strict;
+
#
no strict;
sub AUTOLOAD
{
my $self = shift;
sub AUTOLOAD
{
my $self = shift;
+ no strict;
my $name = $AUTOLOAD;
return if $name =~ /::DESTROY$/;
my $name = $AUTOLOAD;
return if $name =~ /::DESTROY$/;
- $name =~ s/.*:://o;
+ $name =~ s/
^
.*:://o;
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
# this clever line of code creates a subroutine which takes over from autoload
# from OO Perl - Conway
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
# this clever line of code creates a subroutine which takes over from autoload
# from OO Perl - Conway
- *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ;
- if (@_) {
- $self->{$name} = shift;
- }
- return $self->{$name};
+ *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}};
+ &$AUTOLOAD($self, @_);
+# *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ;
+# if (@_) {
+# $self->{$name} = shift;
+# }
+# return $self->{$name};
}
}
-use strict;
+
#
use strict;
#
# initialise the system
#
# initialise the system
@@
-121,6
+128,7
@@
sub init
}
$filename = $fn;
}
$filename = $fn;
+ $lru = LRU->newbase("DXUser", $lrusize);
}
sub del_file
}
sub del_file
@@
-182,8
+190,16
@@
sub get
my $pkg = shift;
my $call = uc shift;
my $data;
my $pkg = shift;
my $call = uc shift;
my $data;
+
+ # is it in the LRU cache?
+ my $ref = $lru->get($call);
+ return $ref if $ref;
+
+ # search for it
unless ($dbm->get($call, $data)) {
unless ($dbm->get($call, $data)) {
- return decode($data);
+ $ref = decode($data);
+ $lru->put($call, $ref);
+ return $ref;
}
return undef;
}
}
return undef;
}
@@
-233,7
+249,9
@@
sub put
$dbm->del($call);
delete $self->{annok} if $self->{annok};
delete $self->{dxok} if $self->{dxok};
$dbm->del($call);
delete $self->{annok} if $self->{annok};
delete $self->{dxok} if $self->{dxok};
- $dbm->put($call, $self->encode);
+ $lru->put($call, $self);
+ my $ref = $self->encode;
+ $dbm->put($call, $ref);
}
#
}
#
@@
-277,6
+295,7
@@
sub del
# for ($dbm->get_dup($call)) {
# $dbm->del_dup($call, $_);
# }
# for ($dbm->get_dup($call)) {
# $dbm->del_dup($call, $_);
# }
+ $lru->remove($call);
$dbm->del($call);
}
$dbm->del($call);
}
@@
-566,6
+585,16
@@
sub wantann_talk
return _want('ann_talk', @_);
}
return _want('ann_talk', @_);
}
+sub wantusers
+{
+ return _want('users', @_);
+}
+
+sub wantsendusers
+{
+ return _want('annsendusers', @_);
+}
+
sub wantlogininfo
{
my $self = shift;
sub wantlogininfo
{
my $self = shift;