0
\$\begingroup\$

I'm building a tooltip item like that

enter image description here

I would like to keep this information cached on the client side, avoiding that whenever the information is displayed it's necessary to make a request to the server, but make the cache is not the problem, the problem is that an item can have its attributes modified and the cache on the client side will show wrong information.

My question is, cache is a good idea? if yes what is the best solution?

\$\endgroup\$
  • \$\begingroup\$ They say there are only two hard problems in computer science: cache invalidation and naming things. ;) What events would cause an item's attributes to be modified? Does the system performing the modification have the ability to send a message that causes the cached info to be updated or cleared? If not, what specific obstacles do we need to overcome between these two pieces of your game? \$\endgroup\$ – DMGregory Nov 10 '18 at 5:28
  • \$\begingroup\$ @DMGregory yes, its possible to send a message to the client when something is changed in item \$\endgroup\$ – Leohige Nov 10 '18 at 20:17
  • \$\begingroup\$ Cool. So, what have you tried so far when implementing this? Is part of it not working, or are you stuck on a particular piece of the implementation? \$\endgroup\$ – DMGregory Nov 10 '18 at 20:18
  • \$\begingroup\$ Send the information to the client will be easy using a new opcode, but I have a new doubt now. The inventory can be closed/opeded, so should I clean the cache always the inventory is closed? or keep it? The item can be dropped on the ground or been traded with another player, the cache could be a problem in that case? \$\endgroup\$ – Leohige Nov 10 '18 at 23:07
0
\$\begingroup\$

The short answer is exactly the same way you would update any other information inside your game. You will generate an update to the item tool-tip anytime that it changes and the cache will display that instead.

\$\endgroup\$
  • \$\begingroup\$ I should send all the info about the item or specific info? \$\endgroup\$ – Leohige Nov 10 '18 at 20:17
  • \$\begingroup\$ That depends entirely on how you normally deal with updates. If your code is made to handle partial updates then specific info would work, if however your code simply replaces it with the network version then the whole item would be required \$\endgroup\$ – TurtleKwitty Nov 11 '18 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.