Peruttu

php memcache code optimization

we recently hired a coder to program and cache some stuff for us in memcache.

after it was completed it worked great and took a major load off our database servers, but it also has caused us some lag.

normally when the site loaded instantly, now with memcache it takes a 2 second + period to "find" the page and then start the loading process.

We removed memcache and did more time trials and the problems went away, so we know 100% its directly linked to memcache,

1st off we are not sure if memcache is supposed to slow a site down by 2+ seconds, but it doesnt seem right

we would like someone to review over the code we post and tell us if its possible to optimzize it or do something with the server settings to get memcache to load super fast.

thanks

tommy

$mch = new Memcache;

$tmp = $mch->get(MC_PREFIX.'active_games_ids');

if(!$tmp) {

$query = "SELECT `id` FROM `games` WHERE `active`='Yes' ORDER BY `id`";

$res = $db->query($query);

$game_ids = array();

while($row = mysql_fetch_row($res)) {

$game_ids[$row[0]] = 1;

}

$mch->set(MC_PREFIX.'active_games_ids',$game_ids,MEMCACHE_COMPRESSED, 24*60*60);

}

else {

$game_ids = $tmp;

}

unset($game_ids[$trout['id']]);

$rand_ids = array_rand($game_ids,$themecfg['hrandomgames']);

ALSO

$tmp = $mch->get(MC_PREFIX.'newest_games_ids');

if(!$tmp) {

$query = "SELECT `id` FROM `games` WHERE `active`='Yes' ORDER BY time DESC";

$res = $db->query($query);

$game_ids = array();

while($row = mysql_fetch_row($res)) {

$game_ids[$row[0]] = 1;

}

$mch->set(MC_PREFIX.'newest_games_ids',$game_ids,MEMCACHE_COMPRESSED, 6*60*60);

}

else {

$game_ids = $tmp;

}

$game_ids = array_slice($game_ids, 0, min(32, count($game_ids)), true);

Those are 2 samples... All we need is about 6 of these recoded, if it doesnt improve performance speed we cannot afford to pay anything

Taidot: PHP

Näytä lisää: php memcache, memcache optimization, php memcache slow, php memcache optimization, memcache optimize query, memcached slow, php program code, our code, new hired, get right code, find php, find instantly, find code, fast min, coder hired, code get, memcache php optimization, super fast memcache, memcache query, memcache code samples, memcache php jobs, php memcache select query, issues php memcache database, memcache save arrays slow, server code

About the Employer:
( 42 reviews ) Austin, United States

Projektin tunnus: #453714

4 freelanceria on tarjonnut keskimäärin 170 $ tähän työhön

cheapestandbest

We have read and review all the detail requirements and confident to take up the challenges .looking forward for your kind consideration on this project.

200 $ USD 3 päivässä
(604 arvostelua)
8.8
devservice

Check PM. Thanks.

100 $ USD 1 päivässä
(95 arvostelua)
5.7
azsolution

Hello, allow me to help you. Please contact with me and we will discuss about this project. Thanks.

80 $ USD 1 päivässä
(21 arvostelua)
5.3
musaulker

I was bidded on your previous project and you cancelled..

250 $ USD 0 päivässä
(18 arvostelua)
5.0
itamarjp

I will analize and make your load go down.

250 $ USD 1 päivässä
(31 arvostelua)
4.6