cache.Cacher comes with a variety of configuration options(cache.Options):
//...m.Use(cache.Cacher(cache.Options{// Name of adapter. Default is "memory". Adapter: "memory",// Adapter configuration, it's corresponding to adapter. AdapterConfig: "",// GC interval time in seconds. Default is 60. Interval: 60,// Configuration section name. Default is "cache". Section: "cache", }))//...
Adapters
There are 8 built-in implementations of cache adapter, you have to import adapter driver explicitly except for memory and file adapters.
Following are some basic usage examples for adapters.
There is a special occupy mode for Redis cacher when you want to use entire database selection with large amount of cache data. By setting OccupyMode to true to enable this mode, then cacher will stop maintaining the index collection of cache data that is used to determine what data are belonging to your app, and helps you reduce CPU and memory usage in such cases.