Sign In Register

How can we help you today?

Start a new topic
Answered

SparkCache put

Hi,

lets say that in SparkCache I have value named "cachedVal", how can I replace it instead of remove and put it again? I mean how can I made atomic request to cache? Because now if I have 1kk users and everyone makes something like this:

if(cache.get("cachedVal") != null)

{

  cache.remove("cachedVal");

  cache.put("cachedVal", newVal);

}

I get a lot of crashes because they in the same time make remove and put requests. Is there any solution for atomic cache request or to solve this problem?


Best Answer

Hi Marcin,


Have you considered making use of Spark.lockKey?


-Pádraig


Answer

Hi Marcin,


Have you considered making use of Spark.lockKey?


-Pádraig


1 person likes this
Great, thank you

 

Btw do you know how lock will behave if between lock and unlock will be some script breaking crash? Will lock be removed?

 

Hi Marcin, 


A lock will be relinquished either when it is explicitly released using Spark.unlockKey, or upon termination of the script. 

This includes a scenario where your script encounters a fatal error before that explicit call. 


- Patrick. 


1 person likes this
Thank you for quick response:)

 

Login to post a comment