# Can I use kong.cache without inserting data into the DB?

**URL:** <https://discuss.konghq.com/t/can-i-use-kong-cache-without-inserting-data-into-the-db/4487>\
**Category:** Questions\
**Created:** [September 25, 2019, 12:57am UTC](https://discuss.konghq.com/t/can-i-use-kong-cache-without-inserting-data-into-the-db/4487 "2019-09-25T00:57:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HYUN\_SUK\_JUNG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hyun_suk_jung/32/1122_2.png) [@HYUN\_SUK\_JUNG](https://discuss.konghq.com/u/HYUN_SUK_JUNG)\
**Post date:** [September 25, 2019, 12:57am UTC](https://discuss.konghq.com/t/can-i-use-kong-cache-without-inserting-data-into-the-db/4487/1 "2019-09-25T00:57:46Z")

</div>

I am developing a kong custom plugin.  
Special table data must be referenced on every request in access: handler.  
This data is updated frequently and is large.  
So I tried to use kong.ctx but could not use it because lifetime is only valid in one request.  
So I tried to use kong.cache, but it seems to be required to use the DB. Inserting a large amount of data into the DB seems to be impossible due to performance issues.

ENV:  
kubernetes/postgresql (DB mode)/KONG Ingress/KONG Custom Plugin

Can I insert/delete/update table type data in kong.cache without putting data in DB?

---

<div class="post-metadata">

**Author:** ![rucciva](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/rucciva/32/1391_2.png) [@rucciva](https://discuss.konghq.com/u/rucciva)\
**Post date:** [September 25, 2019, 11:20am UTC](https://discuss.konghq.com/t/can-i-use-kong-cache-without-inserting-data-into-the-db/4487/2 "2019-09-25T11:20:56Z")

</div>

I’ve had the same problem long time ago. It might help regarding using in-memory cache

> [@Plugin development: initialization based on config](https://discuss.konghq.com/t/plugin-development-initialization-based-on-config/1270):
>
> How would one define a function that produce some values (which will be used each time a request comes) based only on the plugin configuration? Running the function each time a request comes is not efficient since the the values generated only depends on the plugin configuration and the computation is quite heavy. If the solution is to use cache to store the values, then how to handle the invalidation, especially when the plugin is deleted or the configuration is updated?

---

<div class="post-metadata">

**Author:** ![HYUN\_SUK\_JUNG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hyun_suk_jung/32/1122_2.png) [@HYUN\_SUK\_JUNG](https://discuss.konghq.com/u/HYUN_SUK_JUNG)\
**Post date:** [September 26, 2019, 8:11am UTC](https://discuss.konghq.com/t/can-i-use-kong-cache-without-inserting-data-into-the-db/4487/3 "2019-09-26T08:11:25Z")

</div>

Thanks for your help.  
That’s exactly what I was looking for.  
I tested and it works fine with the same values in cache on every request as expected.

Thank you.!!!
