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

[DDC-3761] Fixed cache key #1424

Closed
wants to merge 1 commit into from
Closed

[DDC-3761] Fixed cache key #1424

wants to merge 1 commit into from

Conversation

Ragazzo
Copy link

@Ragazzo Ragazzo commented Jun 14, 2015

Related with this one

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3771

We use Jira to track the state of pull requests and the versions they got
included in.

@guilhermeblanco
Copy link
Member

@Ragazzo makes sense to me, however I do want @FabioBatSilva to review it too.

@Ragazzo
Copy link
Author

Ragazzo commented Jun 15, 2015

@guilhermeblanco he reviewed it in Jira task, and said that it is an issue, sure it would be great if he will see this one more time

@FabioBatSilva
Copy link
Member

Looks good to me,

Wondering if we should give up the more readable serialization format here and just hash $entityClass + $identifiers

@Ragazzo
Copy link
Author

Ragazzo commented Jun 15, 2015

@FabioBatSilva note that you can easily go out of the limit for key, if $entityClass is namespaced, than with all prefixes and so on, you can get as it was in my case key with 244 bytes length, that is almost maximum for memcached 250 bytes key length

@DHager
Copy link
Contributor

DHager commented Jun 15, 2015

@Ragazzo : That sounds like a job for individual CacheProvider implementations: To know when a given key is too big for the system they manage, and to hash or truncate the PHP-land key in a responsible way.

Hmm... if you're worried about unexpected truncation, I'd make sure that the "most unique" parts of the ID are expressed at the start of the generated key-string. That way you reduce the chances of collision when part of the end gets chopped off.

@Ragazzo
Copy link
Author

Ragazzo commented Jun 16, 2015

@DHager yes, it is question of cache implementations in particular, just raised this question to avoid unnecessary bugs in future

@Ocramius
Copy link
Member

I agree with @DHager here: the interface says string, not which kind of string. It is up to the CacheProvider to strip/replace invalid characters or sequences of characters.

@Ragazzo
Copy link
Author

Ragazzo commented Jun 16, 2015

@Ocramius so you want to do this replace in memcached provider? I think that current fix is also correct, anyway to avoid fixing any other providers it is better just not to use spaces, not sure why they were used. Anyway i think it is a critical bug, and it should be fixed asap

@Ocramius
Copy link
Member

@Ragazzo the fix fixes the symptom, not the cause, heh

@Ragazzo
Copy link
Author

Ragazzo commented Jun 16, 2015

@Ocramius sure, but i dont think that replacing in memcached or other providers sounds right, if you will use or store the hash of entity key anywhere and then will try to get it without calling providers, maybe by your own implementation you can get in situation that you forgot to replace spaces like it would be done in provider. Anyway, why this situations does not have checks in cache providers, like max key length, spaces, and so on? Should separated issue be open for that to make research on what characters are valid and what not?

@Ocramius
Copy link
Member

Anyway, why this situations does not have checks in cache providers, like max key length, spaces, and so on?

It is indeed a bug in the cache provider, or in the specific cache adapter impl.

Should separated issue be open for that to make research on what characters are valid and what not?

I think so, yes

@Ragazzo
Copy link
Author

Ragazzo commented Jun 16, 2015

Ok, than what is on this PR, should i close it and open separate about memcached cache provider implementation?

@Ocramius
Copy link
Member

@Ragazzo yes please, and thanks! :-)

@Ocramius
Copy link
Member

Also: close after opening the other PR, or we'll lose track of it

@Ragazzo
Copy link
Author

Ragazzo commented Jun 16, 2015

Also: close after opening the other PR, or we'll lose track of it

Ok

@Ragazzo
Copy link
Author

Ragazzo commented Aug 10, 2015

@Ocramius i'll try to get back to this one asap on weekend, let me know if i should speed up or if it will take too long feel free to fix it as was described )

@lcobucci
Copy link
Member

I've opened doctrine/cache#208 to keep track of this issue, so we can close this PR.

@lcobucci lcobucci closed this Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants