# Add more cache implementations to benchmarking suite

**URL:** <https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707>\
**Category:** Issues\
**Tags:** ristretto, kind:enhancement, priority:p2, status:accepted\
**Created:** [October 1, 2019, 4:12pm UTC](https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707 "2019-10-01T16:12:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [October 1, 2019, 4:12pm UTC](https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707/1 "2019-10-01T16:12:58Z")

</div>

**Moved from GitHub [ristretto/83](https://github.com/dgraph-io/ristretto/issues/83)**

_Posted by_ [karlmcguire](https://github.com/karlmcguire):

- [GitHub - jamiealquiza/bicache: A hybrid MFU / MRU, TTL, sharded cache for Go (aka LFU / LRU)](https://github.com/jamiealquiza/bicache)
- [GitHub - muesli/cache2go: Concurrency-safe Go caching library with expiration capabilities and access counters](https://github.com/muesli/cache2go)

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [October 1, 2019, 4:16pm UTC](https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707/2 "2019-10-01T16:16:07Z")

</div>

[karlmcguire](https://github.com/karlmcguire) _commented_ :

@muesli Is there a way to set a hard memory/item limit on cache2go?

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [October 1, 2019, 4:24pm UTC](https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707/3 "2019-10-01T16:24:15Z")

</div>

[muesli](https://github.com/muesli) _commented_ :

I have been looking into that some years ago, but at least back then it wasn’t really possible to achieve that reliably. For example if you’d use cache2go to store pointers, there wasn’t a way to accurately calculate the underlying objects memory requirements.

I assume this is possible these days with the help of reflection?

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [October 1, 2019, 4:40pm UTC](https://discuss.dgraph.io/t/add-more-cache-implementations-to-benchmarking-suite/8707/4 "2019-10-01T16:40:05Z")

</div>

[karlmcguire](https://github.com/karlmcguire) _commented_ :

> I assume this is possible these days with the help of reflection?

Funny you should ask, it’s currently being [discussed](https://github.com/golang/go/issues/34561#issuecomment-536886728). Ristretto just leaves it up to the user to determine the size of items and provide it when calling Set (as the `cost` parameter). We assume people storing pointers (slices, etc.) should have a reasonable guess of the underlying memory usage.

The reason I ask is for our hit ratio benchmarking we try to ensure that all implementations have the same “size” as to not skew the numbers.
