func (m *memcacheData) mkDataItemLocked(now time.Time, i mc.Item) (ret *mcDataItem) { m.casID++ exp := time.Time{} if i.Expiration() != 0 { exp = now.Add(i.Expiration()).Truncate(time.Second) } value := make([]byte, len(i.Value())) copy(value, i.Value()) return &mcDataItem{ flags: i.Flags(), expiration: exp, value: value, casID: m.casID, } }
func (m *memcacheData) setItemLocked(now time.Time, i mc.Item) { if cur, ok := m.items[i.Key()]; ok { m.stats.Items-- m.stats.Bytes -= uint64(len(cur.value)) } m.stats.Items++ m.stats.Bytes += uint64(len(i.Value())) m.items[i.Key()] = m.mkDataItemLocked(now, i) }