LRUCacheFilter
This class implements the fastcheck.Filter interface using an underlying LRUCache. It leverages a thread-safe LRU cache implementation for its filtering operations.
Methods
Contains()
@classmethod
def Contains(
_: context.Context,
id: []byte
) - > bool
Checks if an item with the given ID is present in the cache. Callers use this to determine if an item has been previously added.
Parameters
| Name | Type | Description |
|---|---|---|
| _ | context.Context | The context for the operation, typically used for cancellation or deadlines. |
| id | []byte | The byte slice identifier of the item to check for existence in the cache. |
Returns
| Type | Description |
|---|---|
bool | True if the item is found in the cache, False otherwise. |
Add()
@classmethod
def Add(
_: context.Context,
id: []byte
) - > bool
Adds an item with the given ID to the cache. Callers use this to store an item, making it available for subsequent 'Contains' checks.
Parameters
| Name | Type | Description |
|---|---|---|
| _ | context.Context | The context for the operation, typically used for cancellation or deadlines. |
| id | []byte | The byte slice identifier of the item to add to the cache. |
Returns
| Type | Description |
|---|---|
bool | True if the item was successfully added to the cache, False otherwise (e.g., if it was already present). |