Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Cache interface is not extensible #381

Closed
bgavrilMS opened this issue Feb 5, 2023 · 1 comment · Fixed by #395
Closed

[Feature Request] Cache interface is not extensible #381

bgavrilMS opened this issue Feb 5, 2023 · 1 comment · Fixed by #395
Labels
enhancement New feature or request GA

Comments

@bgavrilMS
Copy link
Member

bgavrilMS commented Feb 5, 2023

The current cache interface is not extensible enough. Adding new features to the cache is difficult.

At a minimum, the interface should be changed to allow modification.

Note: this proposal is somewhat orthogonal to #379, but #379 does show the difficulty of evolving the interface.

Existing interface

type ExportReplace interface {
	Replace(cache Unmarshaler, key string)
	Export(cache Marshaler, key string)
}

Proposal 1

type ExportReplace interface {
	Replace(cache Unmarshaler, hints CacheHints)
	Export(cache Marshaler, hints CacheHints)
}

Where CacheHints is an object. Adding extra properties to objects allows the interface to evolve.
Currently this object would have 1 property, key string (I suggest renaming it, as key is a bit generic, in .NET use SuggestedCacheKey).

In the future we can have: hasTokens boolean, suggesedExpiryDate datetime

Proposal 2

Same as proposal 1, but switch to a Read/Write/Delete interface + context object. Export / Replace seems more cryptic.

@bgavrilMS
Copy link
Member Author

CC @pmaytak for the Marshaler / Unmarshaler abstraction used here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GA
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant