Aviso: apc_fetch(): fin inesperado de los datos serializados

I'm tring to cache a list of categories for a forum.

I've this error : ContextErrorException: Notice: apc_fetch(): Unexpected end of serialized data in C:\wamp\www\project\vendor\doctrine\cache\lib\Doctrine\Common\Cache\ApcCache.php line 40

El controlador:

<?php
namespace Acme\ForumBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Doctrine\Common\Cache\ApcCache;

class DefaultController extends Controller
{
    public function sidebarAction($slug = null)
    {
        $cache = new ApcCache;

        if($cache->contains('ListOfCategories')) {
            $categories = $cache->fetch('ListOfCategories');
        } else {
            $categories = $this->getDoctrine()
                                ->getManager()
                                ->getRepository('AcmeForumBundle:Category')
                                ->getCategories();
            $cache->save('ListOfCategories', $categories, 500);
        }

        return $this->render('AcmeForumBundle:Block:sidebar.html.twig', array(
            'slug'       => $slug,
            'categories' => $categories
        ));
    }
}

Mi config.yml:

# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        query_cache_driver:    apc
        metadata_cache_driver: apc

Para esta línea: metadata_cache_driver: apc I'm not sure if it's required.

My APC configuration:

[APC]
apc.enabled = 1
apc.shm_size = 256M
apc.max_file_size = 5M
apc.stat = 1

Que hice mal ?

PS: APC is correctly installed, phpinfo(); confirm

Muchas Gracias

preguntado el 12 de junio de 14 a las 11:06

1 Respuestas

I found an other way :

configuración.yml

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true
    metadata_cache_driver: apc
    result_cache_driver: apc
    query_cache_driver: apc

Repositorio:

<?php

namespace xxxxxx\ForumBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * CategoryRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class CategoryRepository extends EntityRepository
{
    public function getCategories() {

        $q = $this->createQueryBuilder('c')
                  ->orderBy('c.weight', 'ASC');

        $query = $q->getQuery();

        $query->useResultCache(true, 300, 'list_of_categories');

        return $query->getResult();
    }
}

and remove all "apc line" in the controller

Respondido el 12 de junio de 14 a las 14:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.