# Ristretto

**URL:** https://discuss.dgraph.io/c/user/ristretto/32.md

[Latest](https://discuss.dgraph.io/latest.md) · [Categories](https://discuss.dgraph.io/categories.md) · [Tags](https://discuss.dgraph.io/tags.md)

---

## [About the Ristretto category](https://discuss.dgraph.io/t/about-the-ristretto-category/7272)

<div class="topic-metadata">

**Author:** [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Replies:** 0

</div>

(Replace this first paragraph with a brief description of your new category. This guidance will appear in the category selection area, so try to keep it below 200 characters.) Use the following paragraphs for a longer d…

---

## [Ristretto GetsDropped and KeysEvicted what do they mean? How to reduce them?](https://discuss.dgraph.io/t/ristretto-getsdropped-and-keysevicted-what-do-they-mean-how-to-reduce-them/19715)

<div class="topic-metadata">

**Author:** [@Priyam\_Goenka](https://discuss.dgraph.io/u/Priyam_Goenka)\
**Replies:** 0\
**Last updated:** [January 17, 2025, 12:32pm UTC](https://discuss.dgraph.io/t/ristretto-getsdropped-and-keysevicted-what-do-they-mean-how-to-reduce-them/19715 "2025-01-17T12:32:10Z")

</div>

I recently added metrics for a service where I observed following data at instance level of the Peak data points: Hits: 1.38B Misses: 24M Peak Eviction: 23M Gets Dropped: 530M Sets Dropped: 0 Sets Rejected: 0 Keys Adde…

---

## [\[QUESTION\]: Regarding Multithreading with Ristretto and Cache Sharing Between Programs](https://discuss.dgraph.io/t/question-regarding-multithreading-with-ristretto-and-cache-sharing-between-programs/18938)

<div class="topic-metadata">

**Author:** [@Pollo59](https://discuss.dgraph.io/u/Pollo59)\
**Replies:** 2\
**Last updated:** [September 26, 2023, 8:55pm UTC](https://discuss.dgraph.io/t/question-regarding-multithreading-with-ristretto-and-cache-sharing-between-programs/18938 "2023-09-26T20:55:00Z")

</div>

Hello, I’m currently exploring the use of Ristretto for a significant personal project and have been conducting initial tests on simpler use cases to familiarize myself with the library. I have some doubts, however, and…

---

## [What are uses of ristrettoCache.wait() function?](https://discuss.dgraph.io/t/what-are-uses-of-ristrettocache-wait-function/18836)

<div class="topic-metadata">

**Author:** [@Amit\_Kumar](https://discuss.dgraph.io/u/Amit_Kumar)\
**Replies:** 1\
**Last updated:** [August 15, 2023, 8:22pm UTC](https://discuss.dgraph.io/t/what-are-uses-of-ristrettocache-wait-function/18836 "2023-08-15T20:22:02Z")

</div>

We are planning to use ristretto cache in kyverno. Can anyone tell me what are the uses of the ristretto cache wait() function?? In what scenerios we should use wait() function ??

---

## [Is there a way to find out how many items are in the cache?](https://discuss.dgraph.io/t/is-there-a-way-to-find-out-how-many-items-are-in-the-cache/18505)

<div class="topic-metadata">

**Author:** [@Millione](https://discuss.dgraph.io/u/Millione)\
**Replies:** 1\
**Last updated:** [April 26, 2023, 3:31am UTC](https://discuss.dgraph.io/t/is-there-a-way-to-find-out-how-many-items-are-in-the-cache/18505 "2023-04-26T03:31:11Z")

</div>

I want to know roughly about how many items are in the cache, but I just can’t find the related api.

---

## [Runtime error: index out of range when build with non-amd64 flags](https://discuss.dgraph.io/t/runtime-error-index-out-of-range-when-build-with-non-amd64-flags/15260)

<div class="topic-metadata">

**Author:** [@BlankRain](https://discuss.dgraph.io/u/BlankRain)\
**Replies:** 2\
**Last updated:** [October 14, 2022, 3:09am UTC](https://discuss.dgraph.io/t/runtime-error-index-out-of-range-when-build-with-non-amd64-flags/15260 "2022-10-14T03:09:13Z")

</div>

The same as Runtime error: index out of range \[20\] with length 20 for ristretto panic: runtime error: index out of range \[10\] with length 10 goroutine 262 \[running\]: github.com/dgraph-io/ristretto/z/simd.Search(0x14180…

---

## [The relationship between numCounters and maxCost](https://discuss.dgraph.io/t/the-relationship-between-numcounters-and-maxcost/17208)

<div class="topic-metadata">

**Author:** [@JackColor](https://discuss.dgraph.io/u/JackColor)\
**Replies:** 0\
**Last updated:** [April 25, 2022, 10:16am UTC](https://discuss.dgraph.io/t/the-relationship-between-numcounters-and-maxcost/17208 "2022-04-25T10:16:05Z")

</div>

when use ristretto, what the relationship between numCounters and maxCost ？ I want consume memory 10M, then set maxCost 10M, and cost return 100 bytes,but I found that it was way over the threshold .

---

## [Is ristretto has callback function？](https://discuss.dgraph.io/t/is-ristretto-has-callback-function/14233)

<div class="topic-metadata">

**Author:** [@staticLin](https://discuss.dgraph.io/u/staticLin)\
**Replies:** 2\
**Last updated:** [May 20, 2021, 2:08am UTC](https://discuss.dgraph.io/t/is-ristretto-has-callback-function/14233 "2021-05-20T02:08:09Z")

</div>

some callback function can setup like callback fired when the oldest entry is removed because of its expiration time or no space left for the new entry, or because delete was called. tks for answer

---

## [Failed to write to cache with TTL](https://discuss.dgraph.io/t/failed-to-write-to-cache-with-ttl/13421)

<div class="topic-metadata">

**Author:** [@linih](https://discuss.dgraph.io/u/linih)\
**Replies:** 1\
**Last updated:** [March 26, 2021, 7:17pm UTC](https://discuss.dgraph.io/t/failed-to-write-to-cache-with-ttl/13421 "2021-03-26T19:17:06Z")

</div>

I am using ristretto cache as shown in the official example, but the get operation failed frequently. I think my example entry was not not successfully written to cache (instead of being evicted). Is there any specific s…

---

## [Does ristretto fires event when ttl expires](https://discuss.dgraph.io/t/does-ristretto-fires-event-when-ttl-expires/12499)

<div class="topic-metadata">

**Author:** [@smartaquarius10](https://discuss.dgraph.io/u/smartaquarius10)\
**Replies:** 4\
**Last updated:** [February 2, 2021, 7:09pm UTC](https://discuss.dgraph.io/t/does-ristretto-fires-event-when-ttl-expires/12499 "2021-02-02T19:09:43Z")

</div>

Team, I’m making an app where I have to save data in db and ristretto as well. Does ristretto fires any event on ttl expiration of an object. It would be easier to manage the db in parallel. Especially in oauth servers…

---

## [Using Ristretto as persistent cache](https://discuss.dgraph.io/t/using-ristretto-as-persistent-cache/12334)

<div class="topic-metadata">

**Author:** [@smartaquarius10](https://discuss.dgraph.io/u/smartaquarius10)\
**Replies:** 6\
**Last updated:** [January 19, 2021, 8:45am UTC](https://discuss.dgraph.io/t/using-ristretto-as-persistent-cache/12334 "2021-01-19T08:45:11Z")

</div>

Team, I need to use the in-memory cache for faster access but my use case is not big enough to opt any DB like dgraph or sql. Could you please suggest any design pattern which I can implement to use ristretto as persis…

---

## [Delay when setting a Cache](https://discuss.dgraph.io/t/delay-when-setting-a-cache/12050)

<div class="topic-metadata">

**Author:** [@konethmelathil](https://discuss.dgraph.io/u/konethmelathil)\
**Replies:** 1\
**Last updated:** [December 24, 2020, 1:28am UTC](https://discuss.dgraph.io/t/delay-when-setting-a-cache/12050 "2020-12-24T01:28:54Z")

</div>

In the example provided on the repo it tells us to wait 10 milliseconds. Is there a way to do this without introducing a delay? // wait for value to pass through buffers time.Sleep(10 \* time.Millisecond) func main() {…

---

## [When will a new Ristretto release be tagged?](https://discuss.dgraph.io/t/when-will-a-new-ristretto-release-be-tagged/11211)

<div class="topic-metadata">

**Author:** [@derekperkins](https://discuss.dgraph.io/u/derekperkins)\
**Replies:** 4\
**Last updated:** [November 5, 2020, 11:19pm UTC](https://discuss.dgraph.io/t/when-will-a-new-ristretto-release-be-tagged/11211 "2020-11-05T23:19:28Z")

</div>

There have been 51 commits since the v0.0.3 release, some with seemingly significant improvements. Is the project at a stable point now to tag a new release?

---

## [How to Create cache instance to keep track of n key value pairs of cost 1?](https://discuss.dgraph.io/t/how-to-create-cache-instance-to-keep-track-of-n-key-value-pairs-of-cost-1/11165)

<div class="topic-metadata">

**Author:** [@helloworld](https://discuss.dgraph.io/u/helloworld)\
**Replies:** 4\
**Last updated:** [October 28, 2020, 5:47am UTC](https://discuss.dgraph.io/t/how-to-create-cache-instance-to-keep-track-of-n-key-value-pairs-of-cost-1/11165 "2020-10-28T05:47:44Z")

</div>

As the title says, I want to create a ristretto cache instance which can keep track of n key value pairs of 1 cost.

---

## [Is Ristretto ready for production use?](https://discuss.dgraph.io/t/is-ristretto-ready-for-production-use/10138)

<div class="topic-metadata">

**Author:** [@indrajit](https://discuss.dgraph.io/u/indrajit)\
**Replies:** 1\
**Last updated:** [September 17, 2020, 4:45pm UTC](https://discuss.dgraph.io/t/is-ristretto-ready-for-production-use/10138 "2020-09-17T16:45:26Z")

</div>

The status shows as still not production ready. We have done testing in QA environment and haven’t faced any issues as yet. Is it safe to deploy this on production? Are there any caveats which we should be aware of?

---

## [Cost vs value and limiting memory consumption](https://discuss.dgraph.io/t/cost-vs-value-and-limiting-memory-consumption/9300)

<div class="topic-metadata">

**Author:** [@hkeide](https://discuss.dgraph.io/u/hkeide)\
**Replies:** 2\
**Last updated:** [August 13, 2020, 6:48pm UTC](https://discuss.dgraph.io/t/cost-vs-value-and-limiting-memory-consumption/9300 "2020-08-13T18:48:12Z")

</div>

I have some values I want to cache which are very expensive to generate in terms of processing, and some that are comparatively cheaper but have a bigger size in bytes. As I understand it I can input the cost of generat…

---

## [Using custom KeyToHash in configuration resulting in drop of cache hit ratio](https://discuss.dgraph.io/t/using-custom-keytohash-in-configuration-resulting-in-drop-of-cache-hit-ratio/8374)

<div class="topic-metadata">

**Author:** [@muskan\_sethia](https://discuss.dgraph.io/u/muskan_sethia)\
**Replies:** 12\
**Last updated:** [July 16, 2020, 6:09pm UTC](https://discuss.dgraph.io/t/using-custom-keytohash-in-configuration-resulting-in-drop-of-cache-hit-ratio/8374 "2020-07-16T18:09:32Z")

</div>

Hi, I’m trying to use a custom KeyToHash function in my configuration but it has resulted in a massive drop in cache hit ratio from 90+% to almost 4%. I’ve also updated to the most recent version of ristretto in my app…

---

## [Unable to Get values while using Ristrettro Cache](https://discuss.dgraph.io/t/unable-to-get-values-while-using-ristrettro-cache/7271)

<div class="topic-metadata">

**Author:** [@muskan\_sethia](https://discuss.dgraph.io/u/muskan_sethia)\
**Replies:** 9\
**Last updated:** [June 19, 2020, 9:07am UTC](https://discuss.dgraph.io/t/unable-to-get-values-while-using-ristrettro-cache/7271 "2020-06-19T09:07:39Z")

</div>

Hi, I’m trying to use Ristrettro for my application. While writing the benchmarks for comparison, I’m facing an issue where the Get is not able to find the value even after a time.Sleep(10 \* time.Millisecond) My use ca…
