# Questions about persistent context

**URL:** <https://discourse.nodered.org/t/questions-about-persistent-context/5547>\
**Category:** Developing Nodes\
**Created:** [7 December 2018 00:13 UTC](https://discourse.nodered.org/t/questions-about-persistent-context/5547 "2018-12-07T00:13:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 December 2018 10:44 UTC](https://discourse.nodered.org/t/questions-about-persistent-context/5547/2 "2018-12-07T10:44:14Z")

</div>

> [@drmibell](#):
>
> I want to use persistent context in one of my contributed nodes, but I have a few questions about how it works.

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.

> [@drmibell](#):
>
> Does this mean that the entire cache is flushed every 30 seconds, regardless of whether any of its contents have changed?

No. It only flushes when there are changes to flush, but will ensures it doesn't flush any more frequently than the configured interval.

> [@drmibell](#):
>
> Second, am I right to assume that "flush" here just means refreshing the filesystem copy, so that the copy in memory continues to be used (unless `cache` is `false` )?

Right.

> [@drmibell](#):
>
> Third, is there a way to force a flush from memory to "disk", so that the persistent copy is guaranteed to be up to date?

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.

> [@drmibell](#):
>
> Finally, I want to assume that NR flushes the cache when it shuts down. Is that correct?

Yes. Assuming NR is shutdown cleanly, then the filesystem context plugin flushes its contents as part of its closing down. If NR is abruptly halted then any unflushed data will be lost.

---

_[View the full topic](https://discourse.nodered.org/t/questions-about-persistent-context/5547)._
