ZF-208: Ability to take cache identifier as any string

Issue Type: Improvement Created: 2006-07-07T23:57:35.000+0000 Last Updated: 2007-07-05T14:43:13.000+0000 Status: Resolved Fix version(s): Reporter: Bojan Tesanovic (bojan) Assignee: Fabien MARTY (fab) Tags: - Zend_Cache

Related issues: Attachments:


As requested from Mislav to open this ticket. Ability to set identifier as any kind of string and not just "'Invalid id or tag : must use only [a-zA-A0-9_]'"


<pre class="highlight">
$urlToSomeData = "";

if($data  = $cache->get($urlToSomeData)){
    $data = file_get_contents($urlToSomeData);

I would recommend some fast hashing function on the identifier string, which will produce file name, if this will not corrupt current Cache system.


Posted by Fabien MARTY (fab) on 2006-07-08T16:00:02.000+0000

We have to take some time to think about that.

Because from my point of view, the md5() should be done by the user in such cases and not by Zend_Cache.

Let's take some time to consider this issue.

Posted by Mislav Marohni? (mislav) on 2006-07-09T08:07:36.000+0000

The issue here is to decide how much would we allow to be a cache identifier. I think it's not right for a backend to limit us (like filesystem did). On the other hand, allowing everything would be expensive and maybe we'd have too much trouble with our backends

Posted by Richard Ingham (richard) on 2006-07-25T12:00:14.000+0000

I was thinking about implementing it for myself in a plugin with something along the lines of:

<pre class="highlight">
$identifier = preg_replace('#[^a-zA-Z0-9_]#', '_', $identifier) . '_' . abs(crc32($identifier));

I was under the impression that crc32 was a fast hashing algorithm, but I don't know how expensive this operation would be. Or how useful the crc32 is...

Whatever the solution, perhaps the ability to have all characters in an identifier should be a configurable option, per Zend_Cache object?

Posted by Fabien MARTY (fab) on 2006-09-03T05:53:54.000+0000

After taking some time, I think that the cache identifier must be a string.

If someone want to use a "not string" identifier, it's not difficult to call md5(serialize($yourId)) before calling Zend_Cache.

Let's keep "hacks" out of Zend_Cache.

So I close this task

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.