Ionic storage, replace

I am using IonicStorageModule to store a key value pair in my project, and let’s say the value is a json object named JSONSTORE.
My question is,

I am storing new sets of values in JSONSTORE and using storage.set() on the same key that i already used.

I know that it will replace all the other previous data stored in the storage module.
But is it necessary for me to call storage.remove(key) to maintain performance improvements, or should i simply call storage.set() again without removing anything?

Use storage set. No problem

1 Like

No i mean, will it replace the data i stored with the same key or will it create a new instance of the storage with the same key but different value?

hi @kevred

you can create a same key array and store multiple different values.


1 Like

actually, i am using a setinterval function that calles the storage.set() again and again after some 10 seconds. and it is calling the storage.set() on a same key and the value is changing, but i need only the newest value. My question is whether without calling storage.remove(), will affect my storage performance?

simply calling storage.set() with the same key i called previusly will it remove the old value and store the new set of values or will it create a new instance of the store with the same key but different values?

Will it gets bigger over time? i dont want that to happen

Thank you very much for your replies guys.

It willnreplcae the value

1 Like

in this way you push data to an old variable and then store into localstore

this.allData.push({'new values'});

this.localstore.set('key name',this.allData);

so no multiple storing of the key value pair right?
I dont’t want to use storage.remove() right?

No it will not store the same key value pair multiple times. (Doesn’t make sense to do so neither)
.set() will create and/or replace the key value pair. No need to call .remove()


writing to storage every 10secs may drain the battery though :slight_smile:

So curious about the use case for that!

But i am getting a json object every 10 second from an api that i should use though.
Is there any other method other than storing the value to show it in my page?