Skip to content

Ignore cache for nil on non-nil types? #3

@jwoertink

Description

@jwoertink

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions