Coder Social home page Coder Social logo

Comments (6)

MichaCo avatar MichaCo commented on June 15, 2024 2

@sam-piper @keerthivasanm
Sorry that it took so long but it's finally implemented and will be in the next release.

from cachemanager.

MichaCo avatar MichaCo commented on June 15, 2024

Yup, sounds like a potential improvement

from cachemanager.

killergege avatar killergege commented on June 15, 2024

I'm a bit surprised that this is missing, it's a basic feature for a cache manager !
How do you know that the value returned by Get is a cached value or a default value because the key doesn't exist ?
To me it sounds dangerous to return a value if the key doesn't exist...

from cachemanager.

MichaCo avatar MichaCo commented on June 15, 2024

@killergege That's the normal behavior of caches. If the key doesn't exist, you cannot return anything. And CacheManager returns default(TCacheValue) which is null for value types etc...

The only other option would be throwing a not found exception, which would cause all kinds of other oddness because then you'd have to try/catch every cache call... Which is even worse than a null check...

That being said, a TryGet and/or Exists method will be helpful for non value types.
Although, you can always use the GetCacheItem method which will always return null if a key doesn't exist, independent of the TCacheValue

from cachemanager.

jzabroski avatar jzabroski commented on June 15, 2024

Agreed with MichaC. Null is a meaningless value. If you want a way to reify
a null, create a Maybe wrapper type. There are many projects on github
which provide not only Maybe but Option type as well (to denote optional
parameters/values).
On May 11, 2016 1:08 PM, "MichaC" [email protected] wrote:

@killergege https://github.com/killergege That's the normal behavior of
caches. If the key doesn't exist, you cannot return anything. And
CacheManager returns default(TCacheValue) which is null for value types
etc...

The only other option would be throwing a not found exception, which would
cause all kinds of other oddness because then you'd have to try/catch every
cache call... Which is even worse than a null check...

That being said, a TryGet and/or Exists method will be helpful for non
value types.
Although, you can always use the GetCacheItem method which will always
return null if a key doesn't exist, independent of the TCacheValue


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#46 (comment)

from cachemanager.

sam-piper avatar sam-piper commented on June 15, 2024

+1 - we would really like this feature too. We have cache loading algorithms that we want to transfer from a previous caching implementation that need to test for the existence of keys without transferring any values from the Redis layer, otherwise performance suffers.

For now I'll have to plug this gap manually, would be great to have official support in the CacheManager API.

from cachemanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.