[SOLVED] Cache ignores settings

Hi I’ve got problems setting my caching correct.

I’ve got a container Element with a lot of filter possibilities. I stripped the code to the necessary part:

prototype(sitePackage:PersonContainer) < prototype(Neos.Neos:Content){
  @context.showAsContact = ${q(node).property('showAsContact')}
  @context.hideMoreButton = ${q(node).property('hideMoreButton')}

  ...

  @context.myList = ${q(site).find("[instanceof sitePackage:Page.Person]").filter(...).get()}
  personList = Neos.Fusion:Map {
    items = ${myList}
    itemRenderer = sitePackage:Person {
      hideMoreButtonSetting = ${hideMoreButton}
      showAsContactSetting = ${showAsContact}
      ...
    }
    @process.removeDuplicates = ${Array.unique(value)}
  }

  @cache {
    mode = 'cached'
    entryIdentifier {
      node = ${node}
    }
    entryTags {
      1 = ${Neos.Caching.nodeTag(node)}
      2 = ${Neos.Caching.nodeTag(myList)}
      3 = ${Neos.Caching.descendantOfTag(myList)}
      ...
    }
}

And then there is the person.fusion object:

prototype(sitePackage:Person) < prototype(Neos.Neos:Content){
  ...
  attributes.class = ${'cPerson ' + hideMoreButtonSetting + showAsContactSetting}
  ...

  @cache {
    mode = 'cached'
    entryIdentifier {
      node = ${node}
      hideMoreButtonSetting = ${hideMoreButtonSetting}
      showAsContactSetting = ${showAsContactSetting}
    }
    entryTags {
      1 = ${Neos.Caching.nodeTag(node)}
      ...
    }
}

Depending on the settings in personContainer, mylist will have at least on element to render, but could also have 200 elements. The person is rendered in 4 different ways, depending on hideMoreButton and showAsContact.

If I remove my caching settings in person everything is fine. But of course, it takes very long. If caching is activated its acceptable fast, but the changes for hideMoreButton and showAsContact don’t affect the result.

From documentation (https://docs.neos.io/cms/manual/rendering/caching) I would say the problem is the entryIdentifier. But I didn’t find a way to set this correct.

Any help is welcome.

You have to put your custom values for the entryIdentifier into the @context before using them in the caching config

thx @sebobo for your fast reply. This version solves my problem:

  personList = Neos.Fusion:Map {
    @context.hideMoreButton = ${q(node).property('hideMoreButton')}
    @context.showAsContact = ${q(node).property('showAsContact')}
    items = ${myList}
    itemRenderer = sitePackage:Person {
      hideMoreButtonSetting = ${hideMoreButton}
      showAsContactSetting = ${showAsContact}
      ...
    }
    @process.removeDuplicates = ${Array.unique(value)}
  }

  @cache {
    mode = 'cached'
    entryIdentifier {
      node = ${node}
    }
    entryTags {
      1 = ${Neos.Caching.nodeTag(node)}
      2 = ${Neos.Caching.nodeTag(myList)}
      3 = ${Neos.Caching.descendantOfTag(myList)}
      ...
    }
  }

in combination with this one:

prototype(sitePackage:Person) < prototype(Neos.Neos:Content){
  ...
  attributes.class = ${'cPerson ' +hideMoreButtonSetting +showAsContactSetting}
  ...

  @cache {
    mode = 'cached'
    entryIdentifier {
      node = ${node}
      hideMoreButton = ${hideMoreButtonSetting}
      showAsContact = ${showAsContactSetting}
    }
    entryTags {
      1 = ${Neos.Caching.nodeTag(node)}
      ...
  }
}

Thx for your help!
@context serves the correct solution.

Somehow the last version still had problems. I had to change to:

personList = Neos.Fusion:Map {
  @context.hideMoreButton = ${q(node).property('hideMoreButton')}
  @context.showAsContact = ${q(node).property('showAsContact')}
  @context.parent = ${q(node)}
  items = ${myList}
  itemRenderer = sitePackage:Person {
    hideMoreButtonSetting = ${hideMoreButton}
    showAsContactSetting = ${showAsContact}
    parent = ${parent}
    ...
  }
  @process.removeDuplicates = ${Array.unique(value)}
}

@cache {
  mode = 'cached'
  entryIdentifier {
    node = ${node}
  }
  entryTags {
    1 = ${Neos.Caching.nodeTag(node)}
    2 = ${Neos.Caching.nodeTag(myList)}
    3 = ${Neos.Caching.descendantOfTag(myList)}
    ...
  }
}

and in the persion.fusion:

prototype(sitePackage:Person) < prototype(Neos.Neos:Content){
...
attributes.class = ${'cPerson ' + hideMoreButtonSetting + showAsContactSetting}
...
@context.parent = ${parent}

@cache {
  mode = 'cached'
  entryIdentifier {
    node = ${node}
    hideMoreButtonSetting = ${q(parent).property('hideMoreButton')}
    showAsContactSetting = ${q(parent).property('showAsContact')}
  }
  entryTags {
    1 = ${Neos.Caching.nodeTag(node)}
    ...
  }

}

I don’t understand why, but I got a solution.