Problem/Motivation

Entities are cached with an expire value of CACHE_PERMANENT, however I have a case where I want them to expire after a certain amount of time. The reason in my case is that I use the Pathologic input filter to convert system-path links to aliased-path links (ie, convert /node/123 to /my-alias). Unfortunately when a node's alias changes, links to it inside other nodes become broken, because entitycache is still serving the last rendering of the input filter.

Proposed resolution

Ideally I could react to node aliases being changed, and search the database for any content with a link to that node. However this is for a very large site, with content being edited constantly, so I think that query would be too expensive. So instead I would prefer a simpler approach of letting the cached entities expire after 24 hours. So my proposal is to add an alter hook in entitycache to allow this.

Remaining tasks

Review attached patch

User interface changes

None

API changes

New alter hook

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brockfanning created an issue. See original summary.

brockfanning’s picture

Status: Active » Needs review
FileSize
1.46 KB
bibo’s picture

This seems to be almost exactly what I need, will test the patch soon!

One suggestion already before testing: wouldn't it be better to pass $item to the alter function, so we could add more complex logic, not just based on entity/nodetype?
Also, why not add the possibility to skip the cache set entirely via the alter?

bibo’s picture

..actually, maybe I wont, since this stuff in latest dev seems to allow me to alter the stuff. Though, I still would want control over expiration times as fallback.
Hmm.