Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Make hashing of cache keys optional via a config value #672

Open
rdiaztushman opened this issue Aug 28, 2014 · 9 comments

Comments

@rdiaztushman
Copy link
Contributor

I have a few views that allow me to view/invalidate user cache items, same as with opcache scripts, and although I can see the values of the items cached by f3, it's impossible to tell what the values correspond to since the key is hashed.

I end up seeing a long list of items with keys that look like this:
{prefix}.jsyuwgsbssg.var
{prefix}.plysmskighb.var
{prefix}.posdhjwhngb.var
etc

I'll make a pull request once I have this finished. Default f3 behavior won't change.

@ikkez
Copy link
Collaborator

ikkez commented Aug 28, 2014

You can also just use Cache::instance->set('mykey','myvalue');
this way there won't be any hashed keys in the cached file name.

@rdiaztushman
Copy link
Contributor Author

Of course. But that doesn't address when you do Base::instance->set('mykey', 'myvalue', 900)

@ChrisFrench
Copy link

I agree with this changed, I had a similar problem using the hashed keys.

On Thu, Aug 28, 2014 at 1:21 PM, Rafael Diaz-Tushman <
[email protected]> wrote:

Of course. But that doesn't address when you do
Base::instance->set('mykey', 'myvalue', 900)


Reply to this email directly or view it on GitHub
#672 (comment).

@bcosca
Copy link
Owner

bcosca commented Sep 30, 2014

Hashed keys are necessary to prevent multiple applications sharing a common F3 folder from overwriting conflicting keys.

@boussou
Copy link

boussou commented Sep 30, 2014

I think it is wrong (sharing cache). IMHO I think F3 app should have a "name" like "myapp" and it should end up in a subfolder so that the apps do no share cache. Or there exist a setting for using a custom folder?

@bcosca
Copy link
Owner

bcosca commented Sep 30, 2014

F3 uses whatever cache backend is available or specified. Guess what happens when the cache backend is redis, memcache, wincache, xcache or PHP's apc/apcu and we use only plain identifiers? Debugging multiple apps would be horrible.

@rdiaztushman
Copy link
Contributor Author

Isn't that the purpose behind {prefix}?

@ikkez
Copy link
Collaborator

ikkez commented Sep 30, 2014

@bcosca, he only want the hashing of the key to become configurable, the prefix hash of each cache key, which is for identifying the app, stays untouched.

@ianvonholt
Copy link

To get shared Cache values, which is nice when you have asynchronous workers for example, you can do a quick edit in base.php around line 2237 in the Cache::load function.

$this->prefix = $fw->get('SHARED_CACHE_KEYS') === true ? '' : $fw->hash($_SERVER['SERVER_NAME'] . $fw->get('BASE'));

Then just set the SHARED_CACHE_KEYS variable:

$f3->set('SHARED_CACHE_KEYS', true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants