# Persisting values across restarts and deploys

**URL:** <https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508>\
**Category:** General\
**Created:** [30 June 2023 16:45 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508 "2023-06-30T16:45:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![serendipitist](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@serendipitist](https://discourse.nodered.org/u/serendipitist)\
**Post date:** [30 June 2023 16:45 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/1 "2023-06-30T16:45:59Z")

</div>

I need to persist certain values to disk across restarts and deploys. I found [node-red-contrib-persist](https://flows.nodered.org/node/node-red-contrib-persist) but it appears to have been abandoned and throws some warnings about deprecated calls on startup. Is there a more up-to-date best practice for this?

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [30 June 2023 16:58 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/2 "2023-06-30T16:58:04Z")

</div>

Welcome to the forum!

Have a look at this introduction to context :  
[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

---

<div class="post-metadata">

**Author:** ![serendipitist](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@serendipitist](https://discourse.nodered.org/u/serendipitist)\
**Post date:** [30 June 2023 21:13 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/3 "2023-06-30T21:13:04Z")

</div>

This is awesome, thank you. When are the persisted values loaded and available to functions? I tried tracing out a value in a function.onStart and it was undefined.

---

<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:** [30 June 2023 21:24 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/4 "2023-06-30T21:24:47Z")

</div>

Show us

- what you entered in the function node
- How you setup the context in settings.js
- What you see in the context viewer

---

<div class="post-metadata">

**Author:** ![serendipitist](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@serendipitist](https://discourse.nodered.org/u/serendipitist)\
**Post date:** [3 July 2023 05:20 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/5 "2023-07-03T05:20:18Z")

</div>

This was my error, all is working as expected.

One additional question - I see that I can set the "flushInterval" in settings.js, but is there a way to manually call a flush from a node? I'll only be updating values very intermittently and would prefer to manually force a save if possible.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 July 2023 06:38 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/6 "2023-07-03T06:38:35Z")

</div>

Afaik it only flushes if something has changed so generally it just works.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 July 2023 06:39 UTC](https://discourse.nodered.org/t/persisting-values-across-restarts-and-deploys/79508/7 "2023-07-17T06:39:20Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
