$dbh->do("UPDATE store_name SET name = '$name' WHERE id = '$last_id';");
}
+ _flush_by_name($name);
return $name;
}
__PACKAGE__->register_method(
}
};
- my $name_id = _get_name_id($name);
- my $atime = time;
- my $etime = interval_to_seconds($time);
-
- $dbh->do('INSERT INTO store_expire (id, atime, expire_interval) VALUES (?,?,?);',{},$name_id,$atime,$etime);
+ $self->method_lookup('opensrf.persist.slot.set_expire')->run($name, $time);
return $name;
}
$dbh->do('UPDATE store_expire SET atime = ? WHERE id = ?', {}, time(), $id);
}
+sub set_expire_interval {
+ my $self = shift;
+ my $client = shift;
+ my $slot = shift;
+ my $new_interval = shift;
+
+ my $etime = interval_to_seconds($new_interval);
+ my $sid = _get_name_id($slot);
+
+ $dbh->do('DELETE FROM store_expire where id = ?', {}, $sid);
+ return $slot if ($etime == 0);
+
+ $dbh->do('INSERT INTO store_expire (id, atime, expire_interval) VALUES (?,?,?);',{},$sid,time(),$etime);
+ return $slot;
+}
+__PACKAGE__->register_method(
+ api_name => 'opensrf.persist.slot.set_expire',
+ method => 'set_expire_interval',
+ argc => 2,
+);
+
+
sub _sweep_expired_slots {
return if (shift());
$dbh->do('INSERT INTO storage (name_id,value) VALUES (?,?);', {}, $name_id, JSON->perl2JSON($value));
+ _flush_by_name($name);
+
return 0 if ($dbh->err);
return $name;
}
sub _flush_by_name {
my $name = shift;
my $no_sweep = shift;
+
+ my $name_id = _get_name_id($name);
- _sweep_expired_slots() unless ($no_sweep);
+ unless ($no_sweep) {
+ _update_expire_atime($name);
+ _sweep_expired_slots();
+ }
if ($name =~ /^AUTOGENERATED!!/) {
- my $name_id = _get_name_id($name);
my $count = $dbh->selectcol_arrayref("SELECT COUNT(*) FROM storage WHERE name_id = ?;", {}, $name_id);
if (!ref($count) || $$count[0] == 0) {
$dbh->do("DELETE FROM store_name WHERE name = ?;", {}, $name);
$client->respond( JSON->JSON2perl( $_->[0] ) ) for (@$values);
+ _flush_by_name($name);
return undef;
}
__PACKAGE__->register_method(