luckyframework / luckyframework/lucky_cache
Ignore cache for nil on non-nil types?
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 8
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Say you have some logic that may return nil, but you don't want to cache nil... Is this something where we could do this?
cache.fetch(key, as: String) do
[nil, "string"].sample
end
With this, I specify that the value is String, but if it returns nil, then we don't cache it. Running it again would only cache if the value returns "string". However, doing this...
cache.fetch(key, as: String?) do
[nil, "string"].sample
end
would say that I allow a nil value, so cache whatever I get back, even if it's nil.
I think we can catch that at compile-time and alter the logic. But the question is, would that be nice? Or would that cause issues?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the cache.fetch API and the two Crystal examples to understand how the as: String and as: String? forms currently behave. Define the intended nil-caching semantics and the compile-time conditions before identifying the tests needed to verify both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100