// useMC adds a gae.Memcache implementation to context, accessible // by gae.GetMC(c) func useMC(c context.Context) context.Context { lck := sync.Mutex{} // TODO(riannucci): just use namespace for automatic key prefixing. Flush // actually wipes the ENTIRE memcache, regardless of namespace. mcdMap := map[string]*memcacheData{} return mc.SetRawFactory(c, func(ic context.Context) mc.RawInterface { lck.Lock() defer lck.Unlock() ns := curGID(ic).namespace mcd, ok := mcdMap[ns] if !ok { mcd = &memcacheData{items: map[string]*mcDataItem{}} mcdMap[ns] = mcd } return &memcacheImpl{ mcd, ic, } }) }
// useMC adds a gae.Memcache implementation to context, accessible // by gae.GetMC(c) func useMC(c context.Context) context.Context { return mc.SetRawFactory(c, func(ci context.Context) mc.RawInterface { return mcImpl{AEContext(ci)} }) }