Skip to content

Composite key support (or cache regions?) #86

Closed
@WhitWaldo

Description

@WhitWaldo

I've been using LazyCache quite happily for over a year now, so thank you for the time you've put into this package.

Today, I have a need for composite key support. I would like to be able to key cache entries by a user identifier and by certain argument values used in a given method. That's easily done by just hashing and concatenating the argument values.

However, I would also like to be able to invalidate based on a partial match of this composite key. For example, should a user's properties update, I would like to be able to invalidate the cached values for this user based on their user identifier even though I don't know the values of the remainder of the cached keys.

Your library doesn't seem to handle this out of the box and after a brief look through your implementation, it doesn't look like you have access to any of the keys stored in the cache via the IMemoryCache. I've considered implementing a dictionary to use as a non-authoritative source for the keys in the cache (not using this in a distributed sense today), but I can also see how this could introduce consistency issues if not handled carefully.

Do you have any other suggestions for going about implementing this? I'd be happy to do the work and eventually submit a pull request, but I'd appreciate your thoughts on it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions