Hi,
I have nginx installed working with memcached and php fastcgi.
I can get the php script to add something to the cache just fine, however, depending on how long the string is that I am caching, memcache_set seems to be serializing the string. When I open the page in a browser and it takes the page from memcached, its all messed up looking. It looks like if I am viewing a binary file as text. Again this only happens if the string if very long. The string I am testing with is 12KB in length. However, if I split the string in half, roughly 6KB it works perfectly fine..
I have attached a picture of the the strange output...
here is part of my nginx.conf
------------------------------------------------------------------------------------------------------------------
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
index index.html index.php;
}
location ~* \.php$ {
default_type text/html;
set $memcached_key "index.php";
memcached_pass 127.0.0.1:11211;
error_page 404 405 502 @cache_miss;
}
location @cache_miss {
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
------------------------------------------------------------------------------------------------------------
And the php file...(index.php)
-------------------------------------------------------------------------------------------------------------
$pinfo = "12KB LONG STRING";
$memcache_obj = memcache_connect('127.0.0.1', 11211);
if(!$var = memcache_get($memcache_obj, 'index.php')){
memcache_set($memcache_obj, 'index.php', $pinfo, FALSE, 30);
echo $memcache_obj->get('index.php');
}
--------------------------------------------------------------------------------------------------------
The "echo" in the php file, which will echo the cached data immediately after storing it, works perfect. If I open the page in a browser for the first time (before that string is added the memcache) it displays the VERY LONG STRING perfectly.
However, If I refresh the brower within 30 seconds, the string (coming from memcached) comes out all screwy looking (looks like binary data represented as text)
This is driving me absolutely crazy, anyone have any tips on what I might be doing wrong?
Thanks