Skip to main content

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

NameTypeDescription
_context.ContextThe context for the operation, typically used for cancellation or deadlines.
id[]byteThe byte slice identifier of the item to check for existence in the cache.

Returns

TypeDescription
boolTrue 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

NameTypeDescription
_context.ContextThe context for the operation, typically used for cancellation or deadlines.
id[]byteThe byte slice identifier of the item to add to the cache.

Returns

TypeDescription
boolTrue if the item was successfully added to the cache, False otherwise (e.g., if it was already present).