mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add infrastructure for automated expiration of storage entries
This is used for backends that don't support expiration natively.
This commit is contained in:
parent
8dee733a7d
commit
d07d27453a
12 changed files with 96 additions and 21 deletions
|
@ -16,6 +16,10 @@ export {
|
|||
# Indicates whether this value should overwrite an existing entry
|
||||
# for the key.
|
||||
overwrite: bool &default=T;
|
||||
|
||||
# An interval of time until the entry is automatically removed from the
|
||||
# backend.
|
||||
expire_time: interval &default=0sec;
|
||||
};
|
||||
|
||||
## Opens a new backend connection based on a configuration object.
|
||||
|
@ -95,7 +99,7 @@ function close_backend(backend: opaque of Storage::BackendHandle): bool
|
|||
|
||||
function put(backend: opaque of Storage::BackendHandle, args: Storage::PutArgs): bool
|
||||
{
|
||||
return Storage::__put(backend, args$key, args$value, args$overwrite);
|
||||
return Storage::__put(backend, args$key, args$value, args$overwrite, args$expire_time);
|
||||
}
|
||||
|
||||
function get(backend: opaque of Storage::BackendHandle, key: any): any
|
||||
|
|
|
@ -6210,6 +6210,14 @@ export {
|
|||
};
|
||||
}
|
||||
|
||||
module Storage;
|
||||
|
||||
export {
|
||||
## The interval used by the storage framework for automatic expiration
|
||||
## of elements in all backends that don't support it natively.
|
||||
const expire_interval = 5.0 secs &redef;
|
||||
}
|
||||
|
||||
module GLOBAL;
|
||||
|
||||
@load base/bif/event.bif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue