當前位置: 首頁>>代碼示例>>Golang>>正文


Golang memcache.Delete函數代碼示例

本文整理匯總了Golang中appengine/memcache.Delete函數的典型用法代碼示例。如果您正苦於以下問題:Golang Delete函數的具體用法?Golang Delete怎麽用?Golang Delete使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Delete函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: accept

func accept(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	id := r.FormValue("id")
	intID, err := strconv.ParseInt(id, 10, 64)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	pkg := &Package{}
	key := datastore.NewKey(c, "Package", "", intID, nil)
	err = datastore.Get(c, key, pkg)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	// check if the package is already present
	acceptQuery := datastore.NewQuery("Package").
		Filter("Accepted =", true).
		Filter("Repo =", pkg.Repo)

	var packages []*Package
	keys, err := acceptQuery.GetAll(c, &packages)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	if len(packages) > 1 {
		// just print an error to let admin know
		c.Errorf("More tha one package for repo: %v", pkg.Repo)
	}

	if len(packages) > 0 {
		// update the package and delete
		oldKey := keys[0]
		oldPkg := packages[0]
		oldPkg.Name = pkg.Name
		oldPkg.Description = pkg.Description
		oldPkg.IsLibrary = pkg.IsLibrary
		oldPkg.Category = pkg.Category
		oldPkg.Updated = time.Now()
		if _, err = datastore.Put(c, oldKey, oldPkg); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		if err = datastore.Delete(c, key); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	} else {
		// accept the new package
		pkg.Accepted = true
		if _, err = datastore.Put(c, key, pkg); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	}
	memcache.Delete(c, pkg.Repo)
	memcache.Delete(c, CAT)
	memcache.Delete(c, ALL_QUERY)
}
開發者ID:rif,項目名稱:gopher-web,代碼行數:60,代碼來源:admin.go

示例2: delete

func delete(w http.ResponseWriter, r *http.Request) {
	key := extractKey(r)
	parts := strings.Split(key, "/")
	if len(parts) == 3 {
		result := make(map[string]bool, 1)
		context := appengine.NewContext(r)
		err := memcache.Delete(context, key)
		if err == nil {
			result[key] = true
			contentType, _ := url.QueryUnescape(parts[0])
			if imageTypes.MatchString(contentType) {
				thumbnailKey := key + thumbSuffix + filepath.Ext(parts[2])
				err := memcache.Delete(context, thumbnailKey)
				if err == nil {
					result[thumbnailKey] = true
				}
			}
		}
		w.Header().Set("Content-Type", "application/json")
		b, err := json.Marshal(result)
		check(err)
		fmt.Fprintln(w, string(b))
	} else {
		http.Error(w, "405 Method not allowed", http.StatusMethodNotAllowed)
	}
}
開發者ID:devCPXL,項目名稱:gestion_stock_old,代碼行數:26,代碼來源:main.go

示例3: clearPairingCache

// clear the pairing cache for the specified dish/pair that is changed
func clearPairingCache(c *context, dishKey *datastore.Key, pairingKey *datastore.Key) {
	url := c.lid.Encode() + "/dish/" + dishKey.Encode() + "/pairing/"
	memcache.Delete(c.c, url)
	if pairingKey != nil {
		url += pairingKey.Encode()
		memcache.Delete(c.c, url)
	}
}
開發者ID:mrolig,項目名稱:Curious-Meals,代碼行數:9,代碼來源:mealplanner.go

示例4: unsubscribe

// Unsubscribe removes a feed from the user's feed list.
func unsubscribe(c appengine.Context, feedKey *datastore.Key) error {
	var f FeedInfo
	err := datastore.RunInTransaction(c, func(c appengine.Context) error {
		u, err := getUser(c)
		if err != nil {
			return err
		}

		i := 0
		var k *datastore.Key
		for i, k = range u.Feeds {
			if feedKey.Equal(k) {
				break
			}
		}
		if i >= len(u.Feeds) {
			return nil
		}

		err = fixMissingFieldError(datastore.Get(c, feedKey, &f))
		if err != nil {
			return err
		}

		f.Refs--
		if f.Refs <= 0 {
			if err := f.rmArticles(c); err != nil {
				return err
			}
			if err := datastore.Delete(c, feedKey); err != nil {
				return err
			}

			memcache.Delete(c, articlesMcacheKey(feedKey))

		} else if _, err := datastore.Put(c, feedKey, &f); err != nil {
			return err
		}

		u.Feeds = append(u.Feeds[:i], u.Feeds[i+1:]...)
		return putUser(c, &u)
	}, &datastore.TransactionOptions{XG: true})
	if err != nil {
		return err
	}

	flushUserPageCache(c)

	if f.Refs <= 0 {
		memcache.Delete(c, mcacheFeedsKey)
		memcache.Delete(c, feedKey.StringID())
		return nil
	}

	return memcache.Gob.Set(c, &memcache.Item{Key: feedKey.StringID(), Object: f})
}
開發者ID:eaburns,項目名稱:feedme,代碼行數:57,代碼來源:user.go

示例5: DeleteUser

func DeleteUser(ctx appengine.Context, user *event.User) {
	key := datastore.NewKey(ctx, "ProxyUser", user.Email, 0, nil)
	datastore.delete(ctx, key)
	key1 := USER_CACHE_KEY_PREFIX + User.Email
	key2 := USER_CACHE_KEY_PREFIX + User.AuthToken
	UserTable[key1] = nil, false
	UserTable[key2] = nil, false
	memcache.Delete(key1)
	memcache.Delete(key2)
}
開發者ID:sankark,項目名稱:kyp,代碼行數:10,代碼來源:ds1.go

示例6: delete

// default data handler for "DELETE" to remove one itme
func (self *dataHandler) delete(key *datastore.Key) {
	// delete the item
	err := datastore.Delete(self.c, key)
	check(err)
	// remove this item from the cache
	cacheKey := self.lid.Encode() + self.r.URL.Path
	memcache.Delete(self.c, cacheKey)
	// remove the parent from the cache too
	// strip off the key from the URL
	parentURL := cacheKey[:len(cacheKey)-len(key.Encode())]
	memcache.Delete(self.c, parentURL)
	// also without the /
	memcache.Delete(self.c, parentURL[:len(parentURL)-1])
}
開發者ID:mrolig,項目名稱:Curious-Meals,代碼行數:15,代碼來源:mealplanner.go

示例7: HandleSign

func HandleSign(r *http.Request) (err error) {

	c := appengine.NewContext(r)

	if user.Current(c) == nil {
		panic("Not logged in .. can only post with authenticated users")
	}

	if err := r.ParseForm(); err != nil {
		return err
	}
	g := &Buriggie{
		Content: r.FormValue("bericht"),
		Date:    time.Now(),
	}
	if u := user.Current(c); u != nil {
		g.Author = u.String()
	}
	if _, err := datastore.Put(c, datastore.NewIncompleteKey(c, "Greeting", nil), g); err != nil {
		return err
	}

	// nice and clean
	memcache.Delete(c, "buriggies.list.100")

	return nil
}
開發者ID:kunnig,項目名稱:roegebeern,代碼行數:27,代碼來源:buriggies.go

示例8: DeleteGroup

func DeleteGroup(ctx appengine.Context, group *event.Group) {
	key := datastore.NewKey(ctx, "ProxyGroup", group.Name, 0, nil)
	datastore.delete(ctx, key)
	key1 := GROUP_CACHE_KEY_PREFIX + group.Name
	GroupTable[key1] = nil, false
	memcache.Delete(key1)
}
開發者ID:sankark,項目名稱:kyp,代碼行數:7,代碼來源:ds1.go

示例9: C1Logout

func C1Logout(c appengine.Context) os.Error {
	u := user.Current(c).Email

	itm, err := memcache.Get(c, u+"__c1Sess")
	if err != nil && err != memcache.ErrCacheMiss {
		return err
	}
	if err == memcache.ErrCacheMiss {
		return nil
	}
	skey := string(itm.Value)
	session := c1SessionCookie(skey)

	r, err := http.NewRequest("GET", "https://www.cadetone.aafc.org.au/logout.php", nil)
	if err != nil {
		return err
	}
	injectSession(r, session)
	client := GetClient(c)
	_, err = client.Do(r)
	if err != nil {
		return err
	}

	memcache.Delete(c, u+"__c1Sess")

	return nil
}
開發者ID:qtse,項目名稱:go_fetch,代碼行數:28,代碼來源:fetch.go

示例10: ClearStories

func (cache *Cache) ClearStories(typeKey string) {
	delete(storyListCache, typeKey)

	if err := memcache.Delete(cache.context, typeKey); err != nil && err != memcache.ErrCacheMiss {
		cache.context.Warningf("Error clearing stories from memcache: %v", typeKey, err)
	}
}
開發者ID:DanielGrech,項目名稱:hackernews,代碼行數:7,代碼來源:cache.go

示例11: cachePathTime

func cachePathTime(c appengine.Context, path string) (t int64, err error) {
	t, err = cacheTime(c)
	if err != nil {
		return 0, err
	}

	key := fmt.Sprintf("%d,mtime,%s", t, path)
	item, err := memcache.Get(c, key)
	if err == nil {
		v, err := strconv.ParseInt(string(item.Value), 10, 64)
		if err == nil {
			if chatty {
				c.Infof("cachePathTime %q = %v", key, v)
			}
			return v, nil
		}
		c.Criticalf("memcache.Get %q = %q (%v) - deleting", key, item.Value, err)
		memcache.Delete(c, key)
	}

	var seq int64
	if fi, err := stat(c, path); err == nil {
		seq = fi.Seq
	}

	c.Infof("cachePathTime save %q = %v", key, seq)
	item = &memcache.Item{Key: key, Value: []byte(strconv.FormatInt(seq, 10))}
	if err := memcache.Set(c, item); err != nil {
		c.Criticalf("memcache.Set %q %q: %v", key, item.Value, err)
	}
	return seq, nil
}
開發者ID:0x7cc,項目名稱:rsc,代碼行數:32,代碼來源:app.go

示例12: Delete

func (c *memcacheDriver) Delete(key string) error {
	err := memcache.Delete(c.c, key)
	if err != nil && err != memcache.ErrCacheMiss {
		return err
	}
	return nil
}
開發者ID:rainycape,項目名稱:gondola,代碼行數:7,代碼來源:memcache_appengine.go

示例13: updateHandler

func updateHandler(w http.ResponseWriter, r *http.Request) {
	c := gae.NewContext(r)
	g := goon.FromContext(c)
	if r.Header.Get("X-AppEngine-Cron") != "true" {
		http.NotFound(w, r)
		return
	}
	var ups []UpdateSchedule
	if cache, err := memcache.Get(c, "UpdateSchedule"); err == memcache.ErrCacheMiss {
		q := datastore.NewQuery("UpdateSchedule")
		if _, err := g.GetAll(q, &ups); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
		if val, err := serialize(&ups); err == nil {
			item := memcache.Item{Key: "UpdateSchedule", Value: val, Expiration: time.Hour * 12}
			memcache.Add(c, &item)
		}
	} else if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	} else {
		deserialize(cache.Value, &ups)
	}
	now := time.Now()
	for _, us := range ups {
		if us.IsUpdateTime(now) {
			if err := updateVillage(us, g); err != nil {
				c.Debugf("%v", err)
			}
			memcache.Delete(c, "UpdateSchedule")
		}
	}
	return
}
開發者ID:Blurmint199,項目名稱:Lycos,代碼行數:35,代碼來源:update.go

示例14: serveTwitterCallback

// serveTwitterCallback handles callbacks from the Twitter OAuth server.
func serveTwitterCallback(c *context) error {
	token := c.r.FormValue("oauth_token")
	var ci connectInfo
	_, err := memcache.Gob.Get(c.c, token, &ci)
	if err != nil {
		return err
	}
	memcache.Delete(c.c, token)
	tempCred := &oauth.Credentials{
		Token:  token,
		Secret: ci.Secret,
	}

	httpClient := urlfetch.Client(c.c)
	tokenCred, _, err := oauthClient.RequestToken(httpClient, tempCred, c.r.FormValue("oauth_verifier"))
	if err != nil {
		return err
	}

	if err := c.updateUserInfo(func(u *userInfo) { u.TwitterCred = *tokenCred }); err != nil {
		return err
	}
	http.Redirect(c.w, c.r, ci.Redirect, 302)
	return nil
}
開發者ID:hori-ryota,項目名稱:go-oauth,代碼行數:26,代碼來源:app.go

示例15: ClearDeviceForRandID

// ClearDeviceForRandID clears the cached Device for the specified RandID.
func ClearDeviceForRandID(c appengine.Context, RandID string) {
	mk := prefixDevForRandID + RandID

	if err := memcache.Delete(c, mk); err != nil {
		c.Warningf("Failed to delete %s from memcache: %v", mk, err)
	}
}
開發者ID:icza,項目名稱:iczagps,代碼行數:8,代碼來源:device.go


注:本文中的appengine/memcache.Delete函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。