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.

  • Built-in Implementation available
  • Can be replaced
  • Multi-Implementation suppported
  • Supports cache expiration

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

  1. Create a new Go-Mojito Handler that has a mojito.Cache argument.

    func SomeHandler(ctx mojito.Context, cache mojito.Cache) {}
  2. 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.

  3. Make use of the dependency-injected cache instance

    func SomeHandler(ctx mojito.Context, cache mojito.Cache) {
        cache.Set("key", "value")


No frequently asked questions yet!