I'm developing a chrome extension and I will store objects sent by server.
For example, I will receive:
command = {id:"1", type: "A", size: "B", priority: "C"}
If I had a database, I would insert it as a line in table commands
.
Using chrome.storage, I'm storing an array of these object in key commands
.
But, when I receive a new command by server, I have to get from local storage, update the array and then set again. I'm worried about cases when I receive another command while I'm getting and setting or while I delete a stored command. I'm thinking about semaphores, but I don't know if it's a great idea.
Can someone suggest me what to do?
thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…