title: php apcu_add class instance
body: <p>In the project that I am working on (PHP 7, Slim Framework), there is a service class that needs alot of time to get instanciated. In order to improve the overall performance of the system I though that an implementation as a singleton would help. I decided to use apcu in order to store the class instance and then fetch whenever needed. </p>
  
  <p>My code for adding the instance to the cache is </p>
  
  <pre><code>$config = [ .... ];
  if (!apcu_exists("mediaService")) {
       $mediaService = new \Services\MediaService($config);
       apcu_add("mediaService", $mediaService);
  }
  </code></pre>
  
  <p>When I run it 
  <code>PHP Fatal error:  Uncaught Exception: Serialization of 'Closure' is not allowed</code>. </p>
  
  <p>Any thoughts?</p>