本文整理汇总了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
}