# Discard stored context with ease

**URL:** <https://discourse.nodered.org/t/discard-stored-context-with-ease/2364>\
**Category:** General\
**Created:** [17 August 2018 12:05 UTC](https://discourse.nodered.org/t/discard-stored-context-with-ease/2364 "2018-08-17T12:05:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [17 August 2018 12:05 UTC](https://discourse.nodered.org/t/discard-stored-context-with-ease/2364/1 "2018-08-17T12:05:23Z")

</div>

It may happen that if you are experimenting with you flows and you use context storage you may find at one point that you have a lot of scrap data stored and you may want to just wipe all. With persistable context with caching enabled it is kind of pain.  
Here's a little helper for you.

`[{"id":"45862c08.b69d64","type":"inject","z":"64513f88.6f389","name":"GLOBAL CONTEXT - DISCARD ALL","topic":"","payload":"DISCARD","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":120,"wires":[["b41ba9df.53b0a8"]]},{"id":"b41ba9df.53b0a8","type":"function","z":"64513f88.6f389","name":"DISCARD","func":"var keys = global.keys();\nfor(var i=0;i<keys.length;i++){\n global.set(keys[i]);\n}\nnode.warn(\"global context cleared!\");","outputs":1,"noerr":0,"x":440,"y":120,"wires":[[]]}]`

It wipes all so handle with care 🙂

---

<div class="post-metadata">

**Author:** ![jhmluna](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jhmluna/32/5395_2.png) [@jhmluna](https://discourse.nodered.org/u/jhmluna)\
**Post date:** [5 February 2019 17:23 UTC](https://discourse.nodered.org/t/discard-stored-context-with-ease/2364/2 "2019-02-05T17:23:45Z")

</div>

Hi.  
Does this works for flow context?  
How would be?  
Thanks.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [5 February 2019 17:40 UTC](https://discourse.nodered.org/t/discard-stored-context-with-ease/2364/3 "2019-02-05T17:40:14Z")

</div>

Have you tried to replace `global` with `flow` in function node?
