mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58: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
|
@ -32,10 +32,12 @@ public:
|
|||
* @param key the key for the pair
|
||||
* @param value the value for the pair
|
||||
* @param overwrite whether an existing value for a key should be overwritten.
|
||||
* @return A result pair containing a bool with the success state, and a
|
||||
* possible error string if the operation failed.
|
||||
* @param expiration_time the time when this entry should be automatically
|
||||
* removed. Set to zero to disable expiration.
|
||||
* @return An optional value potentially containing an error string if
|
||||
* needed. Will be unset if the operation succeeded.
|
||||
*/
|
||||
ErrorResult Put(ValPtr key, ValPtr value, bool overwrite = true);
|
||||
ErrorResult Put(ValPtr key, ValPtr value, bool overwrite = true, double expiration_time = 0);
|
||||
|
||||
/**
|
||||
* Retrieve a value from the backend for a provided key.
|
||||
|
@ -99,7 +101,7 @@ protected:
|
|||
/**
|
||||
* The workhorse method for Put().
|
||||
*/
|
||||
virtual ErrorResult DoPut(ValPtr key, ValPtr value, bool overwrite = true) = 0;
|
||||
virtual ErrorResult DoPut(ValPtr key, ValPtr value, bool overwrite = true, double expiration_time = 0) = 0;
|
||||
|
||||
/**
|
||||
* The workhorse method for Get().
|
||||
|
@ -111,6 +113,12 @@ protected:
|
|||
*/
|
||||
virtual ErrorResult DoErase(ValPtr key) = 0;
|
||||
|
||||
/**
|
||||
* Removes any entries in the backend that have expired. Can be overridden by
|
||||
* derived classes.
|
||||
*/
|
||||
virtual void Expire() {}
|
||||
|
||||
TypePtr key_type;
|
||||
TypePtr val_type;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue