GithubHelp home page GithubHelp logo

Comments (4)

viniciusvarzea avatar viniciusvarzea commented on June 1, 2024 1

Wow, @jodydonetti you did a really good job alone. Thank you bro

from fusioncache.

jodydonetti avatar jodydonetti commented on June 1, 2024

Hi @viniciusvarzea and thanks for using FusionCache!

Your need, if I got it right, is already taken care of by FusionCache itself when disposing the ServiceProvider, which usually happens automatically when the host app shuts down.

Basically, since any singleton service registered via DI has been requested at least once, it's the job of the DI container to dispose it, if the class implements IDisposable or a corresponding interface.

By doing so, any instance of IFusionCache that has been requested will be disposed, too.

Nitpicking corner (in case you are interested)

The so called "default cache" (meaning the FusionCache instance registered via AddFusionCache() with the default name) is requested to the service provider via the IFusionCache interface, so if it has been required even once, it will be automatically disposed.

For the named caches instead (the ones registered via AddFusionCache("name") with a custom name), what gets registered underneath is a LazyNamedCache service per each cache, which in turn can provide the actual named cache when asked: this has been done so that I can enumerate all the registered ones internally via a ctor param of type IEnumerable<LazyNamedCache> and then only if and when asked for one in particular, that cache will be actually instantiated and so, later on, disposed.
In this way if you register 20 different named caches but then only work with 1, you'll only instantiate 1 (and later on automatically dispose it).

Hope this helps.

from fusioncache.

viniciusvarzea avatar viniciusvarzea commented on June 1, 2024

Hello @jodydonetti thank you for the further response. I was worried about the dispose of the cache instances.

Thank you for the excellent project, you guys really rock.

from fusioncache.

jodydonetti avatar jodydonetti commented on June 1, 2024

Hello @jodydonetti thank you for the further response. I was worried about the dispose of the cache instances.

Good, so I'll close this!

Thank you for the excellent project, you guys really rock.

Thanks, even though "us guys" it's just me 😅

image

from fusioncache.

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.