views:

129

answers:

1

Hi all,

I am working on a grid based treasure hunt like game in PHP , mySQL and I am trying to decide between two caching options.

Game Description The user has a 1000 cell grid, clicking on some cells will have no effect, others will direct you to a "this item has been found!" page :)... many items are accessible via any of a number of touching cells (a group).

Process

When a user clicks on a cell I have a JS script that can detect which cell was clicked... it then either:

Option 1: compares it to a comma separated list of 'item' cells from a memory cached mysql response. if the clicked cell is one of the 'item' cells it directs the user to an address like .../grid/cellnumber.php then if that cell number is part of a group (explained above in the game description) it redirects the user to the lowest cell number within the group which contains the "this item has been found!" page.

or

Option 2: compares it to a multidimensional array containing group and cell number e.g item[group no, cell no] then if the cell clicked matches a cell no it directs the user to .../grid/group no.php

Option 2 is obviously neater but I think it requires roughly double the memory when its cached as it requires storing the cell and group number

what does everyone else think?

+1  A: 

Access to disk is measured in milliseconds, Access to Memory is measured in nanoseconds. Memory is much faster.

With a 1000 cell grid even if you have 1 MB of data in each cell it will still fit in the memory of a newer PC.

Shiraz Bhaiji