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

Add Serialization option #411

Merged
merged 5 commits into from
Apr 17, 2018
Merged

Add Serialization option #411

merged 5 commits into from
Apr 17, 2018

Conversation

yellow1912
Copy link
Contributor

Serialization option is necessary for setting the type of serialization
to use for redis.

This is simply a new commit with all the code taken from PR#199 using
the latest code of SncRedisBundle on branch 2.1

Serialization option is necessary for setting the type of serialization
to use for redis.

This is simply a new commit with all the code taken from PR#199 using
the latest code of SncRedisBundle on branch 2.1
@curry684
Copy link
Collaborator

To save us some reviewing effort (see #297 (comment) as well), could you explain briefly the improvements over #297 and why you based on #199 instead?

@@ -114,6 +114,7 @@ private function addClientsSection(ArrayNodeDefinition $rootNode)
->scalarNode('read_write_timeout')->defaultNull()->end()
->booleanNode('iterable_multibulk')->defaultFalse()->end()
->booleanNode('throw_errors')->defaultTrue()->end()
->scalarNode('serialization')->defaultValue("default")->end()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String constants should be in single quotes unless using interpolation.

"none" => 0, // \Redis::SERIALIZER_NONE,
"php" => 1, // \Redis::SERIALIZER_PHP,
"igbinary" => 2 // \Redis::SERIALIZER_IGBINARY
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the dependency on these constants, why can it even be invoked if phpredis is not loaded?

Also single quotes ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to say that we should use this instead?

$types = array(
'none' => 0, \Redis::SERIALIZER_NONE,
'php' => 1, \Redis::SERIALIZER_PHP,
'igbinary' => 2 \Redis::SERIALIZER_IGBINARY
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says we're using the integers instead of the constants as they would fail if phpredis is not loaded, but in that case the serialization wouldn't work anyway, so how come we have to account for it?


// allow user to pass in default serialization in which case we should automatically decide for them
if ('default' == $type) {
if (defined('HHVM_VERSION')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dropped HHVM support so can drop this even if basing on 2.1 as far as I'm concerned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood, I can remove hvvm part

$serializationType = $extension->loadSerializationType($options['serialization']);
$this->assertTrue(is_integer($serializationType));

if (defined('HHVM_VERSION')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - it's a new feature so don't need to support HHVM for BC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove now

@yellow1912
Copy link
Contributor Author

Let me close #297, the reason is that it was from an older version, and since then I made some more changes that shouldn't be in the PR.

Regarding the other changes you commented I will update now.

Regarding #199, it's minor:

  1. Instead of loading all types then check if we support the specific type with loadSerializationTypes, I use loadSerializationType to detect best serialization type to use
  2. The default serialization is not none, if no serialization specified it will use try to detect. This will make this change to work nicely with current applications, otherwise you will have to force clean cache after upgrade because the default was not none I believe.

@yellow1912
Copy link
Contributor Author

@curry684 I made all the changes, the only thing left is your comment regarding "Given the dependency on these constants, why can it even be invoked if phpredis is not loaded?". I was unsure what you meant.

@curry684 curry684 added the feature Introduces new functionality label Apr 12, 2018
@yellow1912
Copy link
Contributor Author

I have updated the code to use Redis class constants directly as per your request.

@curry684
Copy link
Collaborator

Tests failing on:

1) Snc\RedisBundle\Tests\DependencyInjection\SncRedisExtensionTest::testLoadSerializationType
Error: Undefined class constant 'SERIALIZER_IGBINARY'

It's apparently optional: phpredis/phpredis#588

Can you fix it so the code is compatible with IGBINARY support missing as it apparently is on Travis?

Copy link
Collaborator

@curry684 curry684 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs IGBINARY independence.

@yellow1912
Copy link
Contributor Author

Perhaps that was the reason why the hardcoded integer was used instead of the constant, but I think I can fix it.

@curry684
Copy link
Collaborator

There are cleaner ways than hardcoding external integers out of our control ;)

@curry684 curry684 merged commit 5fca27f into snc:2.1 Apr 17, 2018
@curry684
Copy link
Collaborator

Merged, thanks!

curry684 pushed a commit that referenced this pull request Apr 17, 2018
* Add Serialization option

Serialization option is necessary for setting the type of serialization
to use for redis.

This is simply a new commit with all the code taken from PR#199 using
the latest code of SncRedisBundle on branch 2.1

* Minor code style update. Remove HHVM support

* Switch to using Redis Class Constants instead of hard-coded values

* Fix IGBINARY Dependency

* Remove ?? to support php5

(cherry picked from commit 5fca27f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Introduces new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants