… | |
… | |
100 | } |
100 | } |
101 | |
101 | |
102 | $data; |
102 | $data; |
103 | } |
103 | } |
104 | |
104 | |
|
|
105 | use Tie::Cache; |
|
|
106 | tie %statdata_cache, Tie::Cache::, 70; |
|
|
107 | |
105 | sub conn::get_statdata { |
108 | sub conn::get_statdata { |
106 | my $self = shift; |
109 | my $self = shift; |
107 | |
110 | |
108 | my $mtime = $self->{stat}[9]; |
111 | my $mtime = $self->{stat}[9]; |
109 | |
112 | |
|
|
113 | my $statdata = \$statdata_cache{$self->{path}, $mtime}; |
|
|
114 | |
|
|
115 | return $$statdata if $$statdata; |
|
|
116 | |
110 | my $st = sql_exec \my($statdata), |
117 | my $st = sql_exec $statdata, |
111 | "select statdata from diridx where mtime = ? and path = ?", |
118 | "select statdata from diridx where mtime = ? and path = ?", |
112 | $mtime, $self->{path}; |
119 | $mtime, $self->{path}; |
113 | |
120 | |
114 | if ($st->fetch) { |
121 | if ($st->fetch) { |
115 | $statdata = Storable::thaw $statdata; |
122 | $$statdata = Storable::thaw $$statdata; |
116 | return $statdata if $statdata->{version} == $SD_VERSION; |
123 | return $$statdata if $$statdata->{version} == $SD_VERSION; |
117 | } |
124 | } |
118 | |
125 | |
119 | $self->slog(8, "creating index cache for $self->{path}"); |
126 | $self->slog(8, "creating index cache for $self->{path}"); |
120 | |
127 | |
121 | $statdata = $self->gen_statdata; |
128 | $$statdata = $self->gen_statdata; |
122 | $statdata->{version} = $SD_VERSION; |
129 | $$statdata->{version} = $SD_VERSION; |
123 | |
130 | |
124 | sql_exec "delete from diridx where path = ?", $self->{path}; |
131 | sql_exec "delete from diridx where path = ?", $self->{path}; |
125 | sql_exec "insert into diridx (path, mtime, statdata) values (?, ?, ?)", |
132 | sql_exec "insert into diridx (path, mtime, statdata) values (?, ?, ?)", |
126 | $self->{path}, $mtime, Storable::freeze $statdata; |
133 | $self->{path}, $mtime, Storable::freeze $$statdata; |
127 | |
134 | |
128 | $statdata; |
135 | $$statdata; |
129 | } |
136 | } |
130 | |
137 | |
131 | sub conn::diridx { |
138 | sub conn::diridx { |
132 | my $self = shift; |
139 | my $self = shift; |
133 | |
140 | |