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

Request to support strongly typed keys efficiently or using generics #331

Open
brianro opened this issue Feb 12, 2021 · 2 comments
Open

Comments

@brianro
Copy link

brianro commented Feb 12, 2021

Love the library and use it all the time. Will you be introducing strongly typed keys, even if its for a subset of cache providers with limited support? Conversion of objects into string keys e.g. Type or Enum is a pretty expensive option when a strongly typed generic would be more efficient.

I understand the limitations of supporting multiple cache providers, but want to ask the question anyway to get your thoughts please.

Keep up the good work,
B.

@Jmerk523
Copy link

dev...Jmerk523:generics_and_fixes
This is by no means a solution, though it may turn into one. For now, it's a quick-and-dirty (very dirty) replacement of string keys with a generic type parameter.
The changes so far only apply to Core and SystemRuntimeCaching as a proof-of-concept (for myself). There are certainly many bugs, e.g. wrong number of type parameters when reflecting generics. But, it didn't have any major complications, so realistically it could serve as an answer to the 'generic' question, and it may even be usable (for the core classes).
I don't have any plans to bring this to any kind of completion, but the code is there so feel free to use it.

@MichaCo
Copy link
Owner

MichaCo commented May 30, 2021

This might be something I'd consider in a future version, it would break the APIs though and would also require serialization on the key for distributed caches (which is why I didn't want to do that)
But you can always serialize your object and use that as a key manually I guess

@MichaCo MichaCo added this to the Future milestone May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants