blob: 4218acfb6b1a46a0724ab0fc55ad952f0bbdb88c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
package FS::SearchCache;
use strict;
use vars qw($DEBUG);
#use Carp qw(carp cluck croak confess);
$DEBUG = 0;
=head1 NAME
FS::SearchCache - cache
=head1 SYNOPSIS
=head1 DESCRIPTION
=head1 METHODS
=over 4
=item new
=cut
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my( $table, $key ) = @_;
warn "table $table\n" if $DEBUG > 1;
warn "key $key\n" if $DEBUG > 1;
my $self = { 'table' => $table,
'key' => $key,
'cache' => {},
'subcache' => {},
};
bless ($self, $class);
$self;
}
=item table
=cut
sub table { my $self = shift; $self->{table}; }
=item key
=cut
sub key { my $self = shift; $self->{key}; }
=item cache
=cut
sub cache { my $self = shift; $self->{cache}; }
=item subcache
=cut
sub subcache {
my $self = shift;
my $col = shift;
my $table = shift;
my $keyval = shift;
if ( exists $self->{subcache}->{$col}->{$keyval} ) {
warn "returning existing subcache for $keyval ($col)".
"$self->{subcache}->{$col}->{$keyval}\n" if $DEBUG;
return $self->{subcache}->{$col}->{$keyval};
} else {
#my $tablekey = @_ ? shift : $col;
my $tablekey = $col;
my $subcache = ref($self)->new( $table, $tablekey );
$self->{subcache}->{$col}->{$keyval} = $subcache;
warn "creating new subcache $table $tablekey: $subcache\n" if $DEBUG;
$subcache;
}
}
=back
=head1 BUGS
Dismal documentation.
=head1 SEE ALSO
L<FS::Record>, L<FS::cust_main>
=cut
1;
|