Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Don't clone, serialize #17654

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

Merged
merged 1 commit into from
Feb 3, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Cloning is not required by PSR-6, adds overhead and doesn't prevent any mistake for nested objects. Let's simplify.
ArrayCache in turn should store serialized by default, so that data is deep-cloned. But since this can cause a perf issue for some, I propose to add a constructor flag to disable serializing. WDYT?

@stof
Copy link
Member

stof commented Feb 2, 2016

@nicolas-grekas it would be great to look at fixing deps=high jobs (in all affected branches).

This PR looks good to me. The constructor flag allows a performance increase when storing only immutable values (scalars are immutable, references are mutable, arrays are immutable when they contain only immutable values, and objects depend on the class).
I suggest documenting the limitation of disabling serialization though (storing mutable values in such case can lead to a cache corruption)

@nicolas-grekas
Copy link
Member Author

@stof comment added. For the failures, I looked quickly but I'm not familiar enough with the related code. Could someone else have a look at them?

@nicolas-grekas nicolas-grekas force-pushed the ser-cache branch 3 times, most recently from f524aa3 to 089db2d Compare February 3, 2016 08:32
@nicolas-grekas nicolas-grekas merged commit 8605417 into symfony:master Feb 3, 2016
nicolas-grekas added a commit that referenced this pull request Feb 3, 2016
This PR was merged into the 3.1-dev branch.

Discussion
----------

[Cache] Don't clone, serialize

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Cloning is not required by PSR-6, adds overhead and doesn't prevent any mistake for nested objects. Let's simplify.
ArrayCache in turn should store serialized by default, so that data is deep-cloned. But since this can cause a perf issue for some, I propose to add a constructor flag to disable serializing. WDYT?

Commits
-------

8605417 [Cache] Don't clone, serialize
@nicolas-grekas nicolas-grekas deleted the ser-cache branch February 3, 2016 08:39
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants