Welcome Guest, Not a member yet? Register   Sign In
Phil sturgeon's REST Server with memcached

[eluser]Pedro Correia[/eluser]
I've been trying to create a simple REST api for a small project i have going on, using Phils REST Server and it works just fine, except when i tried to integrate memcached to cache database result objects.

I have this simple example:

// check if the object is in cache
  // load the posts model
  // get the data from the database    
  if($posts = $this->MPosts->getPostList($type,$page,$limit))
    // we have a dataset from the database, let's save it to memcached
    // output the response              
  } else {
    // we got nothing to show, output error
    $this->response(array('status'=>false,'message'=>'Fatal error: No data from cache or database.'),404);        
// the object is cached, send it
} else {
      $cache = $this->cache->memcached->get($cachekey);

If i take out the caching part it works great and i get, as i request a perfectly formated json string.

When using caching i get a whitespace before the json string in the response body rendering the request invalid to a REST client.

I've scoured the code up and down and found out that commenting out the code that sets the 'Content-Type' header in the REST_Controller, makes the damned whitespace go away, but that's not really a proper fix.

Can anyone shed some light on this problem please?

Thank you in advance,

STRANGE !!!! I have the same problem with trailing space characters in memcached.php . I try to delete the closed php tags ?> from memchached.php config file, the ajax call is very slow. Does anyone know why?

Theme © iAndrew 2016 - Forum software by © MyBB