go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/gae/service/memcache/types.go (about) 1 // Copyright 2015 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package memcache 16 17 import ( 18 "time" 19 ) 20 21 // Statistics represents a set of statistics about the memcache cache. This 22 // may include items that have expired but have not yet been removed from the 23 // cache. 24 type Statistics struct { 25 Hits uint64 // Counter of cache hits 26 Misses uint64 // Counter of cache misses 27 ByteHits uint64 // Counter of bytes transferred for gets 28 29 Items uint64 // Items currently in the cache 30 Bytes uint64 // Size of all items currently in the cache 31 32 Oldest int64 // Age of access of the oldest item, in seconds 33 } 34 35 // Item is a wrapper around *memcache.Item. Note that the Set* methods all 36 // return the original Item (e.g. they mutate the original), due to 37 // implementation constraints. They return the original item to allow easy 38 // chaining, e.g.: 39 // 40 // itm := memcache.NewItem(c, "foo").SetValue([]byte("stuff")) 41 type Item interface { 42 Key() string 43 Value() []byte 44 Flags() uint32 45 Expiration() time.Duration 46 47 SetKey(string) Item 48 SetValue([]byte) Item 49 SetFlags(uint32) Item 50 SetExpiration(time.Duration) Item 51 52 // SetAll copies all the values from other, except Key, into this item 53 // (including the hidden CasID field). If other is nil, then all non-Key 54 // fields are reset. 55 SetAll(other Item) 56 }