note 112539 added to memcache.get
| From: | jakub dot lopuszanski at nasza-klasa dot pl | Date: | Thu, 27 Jun 2013 14:12:10 +0000 |
| Subject: | note 112539 added to memcache.get | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195376@lists.php.net to get a copy of this message | ||
The comment by bijay dot rungta at gmail dot com could saved us a lot of time, money and users if we
knew about this bug before.
Consider a usual scenario in which you first check something in a cache and only if it is not in
cache, you check in the database.
Something like (in pseudocode):
<?php
$value = $cache->get("resultFor/$x");
if($value is missing){
$value = $database->get($x);
$cache->set("resultFor/$x",$value);
}
return $value;
?>
Now, consider a call to the above function for "dooms day" followed by
"dooms_day". As both keys silently clash, you will get answers to the first query as
results to second query... In particular this missfeature caused our short URLs ( such as
nk.pl/dooms_day) to stop working as as soon as someone typed "nk.pl/dooms%20day" or
"nk.pl/dooms day" or nk.pl/dooms+day", because we only had version with underscore in
our database, yet all of these spellings used the same cache key.
----
Server IP: 69.147.83.199
Probable Submitter: 195.88.186.2
----
Manual Page -- http://php.net/manual/en/memcache.get.php
Edit -- https://master.php.net/note/edit/112539
Del: integrated -- https://master.php.net/note/delete/112539/integrated
Del: useless -- https://master.php.net/note/delete/112539/useless
Del: bad code -- https://master.php.net/note/delete/112539/bad+code
Del: spam -- https://master.php.net/note/delete/112539/spam
Del: non-english -- https://master.php.net/note/delete/112539/non-english
Del: in docs -- https://master.php.net/note/delete/112539/in+docs
Del: other reasons-- https://master.php.net/note/delete/112539
Reject -- https://master.php.net/note/reject/112539
Search -- https://master.php.net/manage/user-notes.php