I’m working on a site that uses over 100,000 short URLs that needs to be requested from an external service (bit.ly). These are requested over a period of time and the cache is built up.

The problem is that when we release a new version of the site Drupal calls cache_clear_all() which completely empties our cache and we need to start the expensive process of requesting these URL’s again.

Drupal’s cache system doesn’t have a solution for durable cache but there is a work around where some of our cache tables are not returned by hook_flush_cache() meaning that Drupal will not attempt to clear them.

It would be great to have that option on the settings page.

CommentFileSizeAuthor
#1 durable-cache-1335166-1.patch2.18 KBJoeMcGuire

Comments

JoeMcGuire’s picture

StatusFileSize
new2.18 KB

Attached is a patch to add the option to not use Drupal's core cache management in Shorten's setting form.

This is probably not the right place for a fix as really we need Drupal's core to support different levels of cache durability however until that happens this patch might be useful to others.

icecreamyou’s picture

Status: Active » Needs work

I can't decide how I feel about this. I don't think there's any precedent. One the one hand a cache is a cache; it gets cleared when you ask for caches to get cleared. To not do that is to break the contract of it being a cache. You can either have persistent data storage or you can use temporary caches; it's a design decision, and caches make sense for Shorten URLs because neither shortened URLs nor the long URLs they represent always last indefinitely (and also using the cache saves an extra read/write per URL to persistent storage). By definition the cache is for things that take awhile to regenerate, so when you clear the cache, you should be aware of the consequences. If you don't want a cache cleared, you can either choose not to clear it, or back it up and restore it after clearing all caches.

On the other hand, I see where you're coming from -- shortened URLs aren't really part of Drupal per se and so they don't really need to be flushed when the rest of Drupal gets flushed, and there is a not-insignificant performance cost to generating them all again. I don't think switching completely to persistent storage makes sense, and yet when you flush all caches you expect that all caches will be flushed.

At the very least, the patch needs a few minor changes: new variables introduced need to be deleted when the module is uninstalled, and "Allow Drupal to clear caches" is more dramatic than it should be. The language should be clear that the purpose of the setting is to make it possible to disable clearing the cache of shortened URLs when Drupal attempts to clear all caches.

icecreamyou’s picture

I decided I'm okay with this change, but the patch still needs the modifications mentioned in #2.

icecreamyou’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.