eZ Community » Forums » eZ Publish 5 Platform » Stash pool cache and Xml Block
expandshrink

Stash pool cache and Xml Block

Stash pool cache and Xml Block

Thursday 03 March 2016 12:48:40 pm - 2 replies

Hello everyone,

I'm trying to use stash pool on some parts on the controller where I'm fetching data from multiple locations, relations, tags etc. I'm using HTTP cache but it varies depend user's as there are some parts that are different for each one. Therefore I decided to use stash pool service for some common parts as below:

Controller:

$cacheService = $this->get('ezpublish.cache_pool');

$cacheItem = $cacheService->getItem('exampleReferences', 'object', $exampleLocation->id);

if ($cacheItem->isMiss()) {

    ... fetching data ...

    $cacheItem->set($params);
} else {
    $params = $cacheItem->get();
}

Parameters.yml:

 stash:
    caches:
        default:
            drivers: [ 'Apc' ]
            inMemory: true
            registerDoctrineAdapter: true
            Apc:
                namespace: "project_dev"

 

It seems to cache well, I left default configuration expiration, 5 days.

The problem is that when in cache there is content with datatype XML Block, the cached result is the following:

Warning: eZ\Publish\Core\FieldType\XmlText\Type::isEmptyValue(): Invalid State Error in /home/.../application/vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/XmlText/Type.php on line 108

Is this a known issue? Is it fixed in a future release, I'm still using 2014.11.

Many thanks for your time

Modified on Thursday 03 March 2016 12:55:51 pm by Matthieu Kapetanos

Friday 04 March 2016 1:20:19 pm

Hi,

 

it looks like you are caching api objects, right?

API objects have some field types that uses XML DomDocument, and you will run into issues as any cache solution like Stash requires that objects you place there are serializable. PHP's DomDocument is not.

In our case we cache objects on a lower level, one we call SPI (Persistence Cache), here these fields must be serializable and string is used for xml, however earlier it was xml and you can see how we handled that there.

As eZ Publish/eZ Platform is already caching content objects, it might be more performance benefit for you to cache higher up, like responses or parts of responses by splitting it up, either with http cache and/or solutions like twig-cache-extension.

So it's a known issue if this is api objects, however as we currently don't have plans to cache at this level ourselves, we haven't planned to fix this. But as always open for suggestions.

 

Best,
André

Modified on Friday 04 March 2016 1:20:49 pm by André R

Saturday 05 March 2016 12:15:11 pm

Yes, it concerns API objects. Well I'll try to find out an other way. Thank you for the explanation

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from