code: func NewDBCache(updater DBCacheUpdater) func(c context.Context) (DB, error) {
  	cacheSlot := lazyslot.Slot{}
  	return func(c context.Context) (DB, error) {
  		val, err := cacheSlot.Get(c, func(prev interface{}) (db interface{}, exp time.Duration, err error) {
  			prevDB, _ := prev.(DB)
  			if db, err = updater(c, prevDB); err == nil {
  				exp = 5*time.Second + time.Duration(mathrand.Get(c).Intn(5000))*time.Millisecond
  			}
  			return
  		})
  		if err != nil {
  			return nil, err
  		}
  		return val.(DB), nil
  	}
  }
docs: // NewDBCache returns a provider of DB instances that uses local memory to
  // cache DB instances for 5-10 seconds. It uses supplied callback to refetch DB
  // from some permanent storage when cache expires.
  //
  // Even though the return value is technically a function, treat it as a heavy
  // stateful object, since it has the cache of DB in its closure.