Can i mutate the field of a value's struct? And how to get the field's value only?

Because ristretto lets us build a cache with different types as the value…If we use a struct as a value, how do we access struct and the struct’s fields? Is this possible?

Let’s say I have struct:

type bucket struct {
	tokens uint
	time   time.Time

And my ristretto cache:

	buckets, err := ristretto.NewCache(&ristretto.Config{
		NumCounters: 1e7,     // number of keys to track frequency of (10M).
		MaxCost:     1 << 30, // maximum cost of cache (1GB).
		BufferItems: 64,      // number of keys per Get buffer.
	if err != nil {

Wich sets a with key:value of [string]struct{}:

ip := ""

buckets.Set(ip, bucket{tokens: max -1 , time: time.Now()}, 1)

Question one: How can i retrieve only the tokens value? Trying to use Get will only return what i think is some numbers and memory addresses:

test, ok := buckets.Get(ip)
	if !ok {
		panic("missing value")


Question 2: How can i update only the field tokens of the cache’s bucket struct?

buckets.Set(ip, bucket{tokens: 3}, 1)

	test, ok = buckets.Get(ip)
	if !ok {
		panic("missing value")

This overwrites the entire key.