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) }
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) }
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) }
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 }