inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 10, 2014 13:57:03 GMT -8
I'm working on a basic store plugin, and it is nearly finished but now I'm dealing with the issue of a key that holds the orders being overwritten. It happens when a person orders an item when their page is outdated; meaning, the key data that they have has been changed recently, when another user order an item, and they have not yet received the new information. In order to receive the current key data, a user must load/refresh the page right before he orders an item - and obviously I can't ask users to do that every time.
I made a thread regarding this earlier and I was told pushing to the key could be the solution, but I still haven't figured it out. If anyone could explain how to do it, or knows of any other solutions to this problem, I will appreciate your response.
Thanks.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Mar 10, 2014 15:15:28 GMT -8
Should be in the plugin dev board It's quite straight forward, just need to make sure you are using the right namespace, method, and passing an object to the method. At first I was confused, as "pb" wasn't an alias for "proboards". www.proboards.com/developer/js/class/key#pushExample: pb.plugin.key("yourkey").push({value: "a"}) Look at the docs for more option properties that you can set. Important note: Your data must be an array, if it's not, it will not work.
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 10, 2014 18:34:12 GMT -8
Thanks for your response.
I currently store the info in the key as JSON, how would I go about this then?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Mar 10, 2014 21:51:53 GMT -8
what does the object look like?
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 11, 2014 20:25:56 GMT -8
I'm storing it as a JSON string with usernames as keys and item names as values. Like so, Admin: Keychain
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Mar 11, 2014 21:19:45 GMT -8
are these user keys or a forum key?
|
|
inherit
203080
0
Mar 17, 2014 14:50:56 GMT -8
baratheon
43
December 2013
baratheon
|
Post by baratheon on Mar 12, 2014 11:20:06 GMT -8
It's one super forum key with a JSON string.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Mar 12, 2014 14:26:04 GMT -8
if this is in regards to accurate inventory, where you have 1 item of something left in the store and someone is being really slow about buying it ans someone else does it faster, there might not be a solution for this. using push will all a key to get additional info without overriding previous info, but if you are subtracting something it still has a race condition.
I havent tried it, but I bet you could put something into the success function of a push, that checks the new contents of the key after the push. if the inventory now is <0 then dont complete whatever transaction they were in the middle of (or reverse it)
|
|
inherit
201984
0
Sept 11, 2023 1:23:07 GMT -8
P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓
Using My Talents Elsewhere
3,314
November 2013
pastuleo23
|
Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on Mar 19, 2014 1:37:16 GMT -8
It's one super forum key with a JSON string. support.proboards.com/thread/505254/You can check out my post on this thread for more info on how I did it with the eshop Now the problem with a JSON string and Push is that they do not comply IF you want to use a JSON string, you will have to make sure that you push it to an Array as many separate json strings (an array filled with your json strings) and when you read the data You will have to split it up and join the strings together and then you will have your json string again. In short, I suggest NOT using a json string when working with arrays The code of the E Shop is open source and commented in so that it might be something you could look at and get some ideas from on how it works under the build tab.
|
|