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

**URL:** <https://discuss.dgraph.io/t/can-i-mutate-the-field-of-a-values-struct-and-how-to-get-the-fields-value-only/15751>\
**Category:** Ristretto\
**Created:** [October 8, 2021, 3:40am UTC](https://discuss.dgraph.io/t/can-i-mutate-the-field-of-a-values-struct-and-how-to-get-the-fields-value-only/15751 "2021-10-08T03:40:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yadang](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/yadang/32/8942_2.png) [@yadang](https://discuss.dgraph.io/u/yadang)\
**Post date:** [October 8, 2021, 3:40am UTC](https://discuss.dgraph.io/t/can-i-mutate-the-field-of-a-values-struct-and-how-to-get-the-fields-value-only/15751/1 "2021-10-08T03:40:49Z")

</div>

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:

```auto
type bucket struct {
	tokens uint
	time time.Time
}

```

And my ristretto cache:

```auto
	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 {
		panic(err)
	}

```

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

```auto
ip := "10.108.1.1"

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

```

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:

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

	fmt.Println(test)

```

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

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

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

```

This overwrites the entire key.
