Overview
Go-Mojito's cache interface provides a dependency-independent way to dependency inject a cache into your handlers and middleware. By default, the built-in in-memory cache is used, but you can easily replace it with a custom implementation like groupcache.
Of course you can also have multiple caches injected by using named dependencies, even without replacing the in-memory cache which can be used for smaller use-cases.
Quick Start
-
Create a new Go-Mojito Handler that has a
mojito.Cache
argument.func SomeHandler(ctx mojito.Context, cache mojito.Cache) {}
Go-Mojito will now detect that you want the default cache injected into your handler. If Go-Mojito was unable to link the dependency, you will see error logs when you start up your web app.
Make use of the dependency-injected cache instance
func SomeHandler(ctx mojito.Context, cache mojito.Cache) { cache.Set("key", "value") }
FAQ
No frequently asked questions yet!