# Persistent global variables

**URL:** <https://discourse.nodered.org/t/persistent-global-variables/41559>\
**Category:** General\
**Created:** [24 February 2021 14:14 UTC](https://discourse.nodered.org/t/persistent-global-variables/41559 "2021-02-24T14:14:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 February 2021 14:21 UTC](https://discourse.nodered.org/t/persistent-global-variables/41559/2 "2021-02-24T14:21:07Z")

</div>

lots of info on the forum (search persistent context )

e.g...

> [@Questions about persistent context](https://discourse.nodered.org/t/questions-about-persistent-context/5547/2):
>
> To begin with, as a node author, you just use Context. You don't get to pick if its persistent or not as that is up to the end user. No. It only flushes when there are changes to flush, but will ensures it doesn't flush any more frequently than the configured interval. Right. No. The context api only lets you get/set values - that is all. You don't know what instance of context plugin the user has configured. Yes. Assuming NR is shutdown cleanly, then the filesystem context plugin flush…

> [@A catch with persistent file stores](https://discourse.nodered.org/t/a-catch-with-persistent-file-stores/21062/2):
>
> You can always change the flush interval; contextStorage: { default: "file", memoryOnly: { module: 'memory' }, file: { module: 'localfilesystem', config: { flushInterval: '10' }, }, },

If you want more control, there are contrib nodes that can read/write to JSON in a very similar fasion to persistent storage e.g...

> **[node-red-contrib-persist](https://flows.nodered.org/node/node-red-contrib-persist)**
>
> A node-red node to persist data between Node Red deploys and restarts.

> **[node-red-contrib-key-value-store](https://flows.nodered.org/node/node-red-contrib-key-value-store)**
>
> Simple, persistent, JSON-based key-value store for Node-RED

---

_[View the full topic](https://discourse.nodered.org/t/persistent-global-variables/41559)._
