本文整理匯總了Golang中github.com/valyala/ybc/bindings/go/ybc.Cacher.Delete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Cacher.Delete方法的具體用法?Golang Cacher.Delete怎麽用?Golang Cacher.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/valyala/ybc/bindings/go/ybc.Cacher
的用法示例。
在下文中一共展示了Cacher.Delete方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: processDeleteCmd
func processDeleteCmd(c *bufio.ReadWriter, cache ybc.Cacher, line []byte, scratchBuf *[]byte) bool {
n := -1
key := nextToken(line, &n, "key")
if key == nil {
return false
}
noreply := false
if n < len(line) {
if !expectNoreply(line, &n) {
return false
}
noreply = true
}
if !expectEof(line, n) {
return false
}
ok := cache.Delete(key)
if noreply {
return true
}
response := strDeleted
if !ok {
response = strNotFound
}
return writeStr(c.Writer, response) && writeCrLf(c.Writer)
}
示例2: revalidateAndSetItemValueInternal
func revalidateAndSetItemValueInternal(client Ccacher, cache ybc.Cacher, it *ybc.Item, item *Item, casid uint64, flags, validateTtl uint32, getFunc func() error) error {
if err := getFunc(); err != nil {
if err == ErrNotModified {
if validateTtl > 0 {
updateLocalItem(cache, it, item.Key, casid, flags, validateTtl)
}
return setItemValue(it, item)
}
if err == ErrCacheMiss {
cache.Delete(item.Key)
}
return err
}
return cacheItem(cache, item)
}
示例3: processDeleteCmd
func processDeleteCmd(c *bufio.ReadWriter, cache ybc.Cacher, line []byte, scratchBuf *[]byte) bool {
n := -1
key := nextToken(line, &n, "key")
if key == nil {
return false
}
noreply := false
if n < len(line) {
s := nextToken(line, &n, "noreply_or_exptime")
if s == nil {
return false
}
if !bytes.Equal(s, strNoreply) {
if _, ok := parseUint32(s); !ok {
return false
}
if n < len(line) {
if !expectNoreply(line, &n) {
return false
}
noreply = true
}
} else {
noreply = true
}
}
if !expectEof(line, n) {
return false
}
ok := cache.Delete(key)
if noreply {
return true
}
response := strDeletedCrLf
if !ok {
response = strNotFoundCrLf
}
return writeStr(c.Writer, response)
}
示例4: revalidateAndSetItemValueInternal
func revalidateAndSetItemValueInternal(client Ccacher, cache ybc.Cacher, it *ybc.Item, item *Item, etag uint64, validateTtl uint32, getFunc func(*Citem) error) error {
citem := Citem{
Item: Item{
Key: item.Key,
},
Etag: etag,
}
if err := getFunc(&citem); err != nil {
if err == ErrNotModified {
if validateTtl > 0 {
updateLocalItem(cache, it, item, etag, validateTtl)
}
return setItemValue(it, item)
}
if err == ErrCacheMiss {
cache.Delete(item.Key)
}
return err
}
cacheCitem(cache, &citem)
item.Value = citem.Value
return nil
}