Sign In Register

How can we help you today?

Start a new topic
Answered

Completely clear Redis?

Is there any way for me to clear all my Redis keys?


Best Answer

var allKeys = Spark.getRedis().keys(*)


for(var i=0 ; i<allKeys.length ; i++){

    Spark.getRedis().del(allKeys[i]);

}


1 person has this question

Hi Ryan,


No we don't support FLUSHDB. As Redis is used for some system purposes as well as custom data the method would clear that data too which would not be ideal. For now you can use the code supplied by Tech Support above to clear the data. I'll add a Feature Request to our backlog on your behalf for a method that will clear custom data.


Thanks,

Liam

Answer

var allKeys = Spark.getRedis().keys(*)


for(var i=0 ; i<allKeys.length ; i++){

    Spark.getRedis().del(allKeys[i]);

}

That makes sense. Just to make sure we're clear: are those system-level Redis entries visible to us? If I remove every key I have access to, I won't accidentally remove any of your system level Redis KVPs?


Thanks for the info.

Hi Ryan,


No they are not visible to you. They aren't exposed so scenarios such as the one described by you above can be avoided.


Thanks,

Liam

or how about Spark.getCache().removeAll() ?

@Tech Support:

So we don't have any access to calls like FLUSHDB


@Jeff:

That is for SparkCache, which is an entirely separate system backed by Mongo. https://docs.gamesparks.com/api-documentation/cloud-code-api/cloud-data/sparkcache.html

Login to post a comment