# Load and save cache

**URL:** <https://discuss.dgraph.io/t/load-and-save-cache/16145>\
**Category:** Ristretto\
**Created:** [November 25, 2021, 7:56am UTC](https://discuss.dgraph.io/t/load-and-save-cache/16145 "2021-11-25T07:56:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tong3jie](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/tong3jie/32/9164_2.png) [@tong3jie](https://discuss.dgraph.io/u/tong3jie)\
**Post date:** [November 25, 2021, 7:56am UTC](https://discuss.dgraph.io/t/load-and-save-cache/16145/1 "2021-11-25T07:56:27Z")

</div>

1. when the program is fist lunch, it needs to load from other storage, example: redis、file、mysql…

2. When the program crashes, the contents in the cache need to be stored in another store

I think may be add a hook to handle it

---

<div class="post-metadata">

**Author:** ![iluminae](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/iluminae/32/7367_2.png) [@iluminae](https://discuss.dgraph.io/u/iluminae)\
**Post date:** [November 25, 2021, 3:24pm UTC](https://discuss.dgraph.io/t/load-and-save-cache/16145/2 "2021-11-25T15:24:20Z")

</div>

You probably should not rely on very complex things to happen 'on signal’s in your program, like flushing the whole cache over a network. You can look up patterns for ‘read through cache’ where everything will be synced in real time to a persistent db, that way a crash/exit is OK, but repeated access is done only in the memory cache.
