coocood/freecache

NewIterator Output ExpiresAt

MarketSmart opened this issue · 5 comments

Could you add ExpiresAt to the iterator. I'm using this with a middle man to sync cluster cache and I want to keep the expire time. Currently we are having to make an additional call to GetWithExpiration which seems kinda inefficient.

	//Loop through all cache entries
	cacheDump := make(map[string]map[string]string)

	iterator := c.store.NewIterator()
	for entry := iterator.Next(); entry != nil; {
		//Itterator wont give us the expiration time so we have to get it
		_, expireAt, _ := c.store.GetWithExpiration(entry.Key)

		//Add the entry to the dump
		cacheDump[string(entry.Key)] = map[string]string{
			"value": string(entry.Value),
			"ttl":   strconv.Itoa(int(expireAt)),
		}
	}

I also has same need, can I slove it? @coocood

@xiehui3651
It's easy to add this feature, just add an ExpireAt field in the Entry struct and in nextForSlot assign the value to it.
Would you like to send a PR for it?

@xiehui3651 It's easy to add this feature, just add an ExpireAt field in the Entry struct and in nextForSlot assign the value to it. Would you like to send a PR for it?
let me try

Closed by #128