8000 [Cache] Add PDO + Doctrine DBAL adapter by nicolas-grekas · Pull Request #19519 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Add PDO + Doctrine DBAL adapter #19519

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
Aug 19, 2016

Conversation

nicolas-grekas
Copy link
Member
@nicolas-grekas nicolas-grekas commented Aug 3, 2016
Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR symfony/symfony-docs#6858

This PR adds a PDO adapter for our PSR-6 cache items. The implementation heavily borrows from PdoSessionHandler.


private function init($pdoOrDsn, $namespace, $defaultLifetime, array $options)
{
if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't strpbrk be more efficient ?

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure, less readable, and not perf critical code path anyway (run once code) :)

@nicolas-grekas nicolas-grekas changed the title [Cache] Add PDO adapter + tag aware adapter [Cache] Add PDO adapter Aug 4, 2016
@nicolas-grekas nicolas-grekas force-pushed the cache-pdo branch 7 times, most recently from ab167dc to dcc7915 Compare August 5, 2016 19:04
/**
* {@inheritdoc}
*/
protected $maxIdLength = 255;
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

phpdoc seems useless to me

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@nicolas-grekas nicolas-grekas changed the title [Cache] Add PDO adapter [Cache] Add PDO + Doctrine DBAL adapter Aug 6, 2016
@nicolas-grekas
Copy link
Member Author

This now also accepts a Doctrine DBAL Connection.

@@ -26,6 +26,7 @@
"require-dev": {
"cache/integration-tests": "dev-master",
"doctrine/cache": "~1.6",
"doctrine/dbal": "~2.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

From a "component" point of view, you may add doctrine/dbal to the suggest section, what do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bof... This would never end: install redis, install apcu, install... etc. No value. Read the doc instead (I'm on it).

@nicolas-grekas nicolas-grekas force-pushed the cache-pdo branch 4 times, most recently from 11e8765 to 5007996 Compare August 16, 2016 16:19
@@ -64,7 +64,7 @@ public function getItem($key)
} elseif ('b:0;' === $value = $this->values[$key]) {
$value = false;
} elseif (false === $value = unserialize($value)) {
$value = null;
$this->values[$key] = $value = null;
Copy link
Member

Choose a reason for hiding this comment

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

isn't this a bugfix which should go separately ?

Copy link
Member Author

Choose a reason for hiding this comment

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

see #19640

break;
case 'pdo_sqlsrv':
$this->driver = 'sqlsrv';
break;
Copy link
Member

Choose a reason for hiding this comment

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

what about handling the default case here, for unknown drivers ?

Copy link
Member Author

Choose a reason for hiding this comment

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

we use only pgsql and sqlsrv, so I'd rather remove all the unused cases than add a default

Copy link
Member Author
@nicolas-grekas nicolas-grekas Aug 16, 2016

Choose a reason for hiding this comment

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

ok, bad answer :) yet, the adapter doesn't handle other drivers, so we don't care for a default case here

@fabpot
Copy link
Member
fabpot commented Aug 19, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 82a0de2 into symfony:master Aug 19, 2016
fabpot added a commit that referenced this pull request Aug 19, 2016
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Cache] Add PDO + Doctrine DBAL adapter

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#6858

This PR adds a PDO adapter for our PSR-6 cache items. The implementation heavily borrows from PdoSessionHandler.

Commits
-------

82a0de2 [Cache] Add PDO + Doctrine DBAL adapter
@nicolas-grekas nicolas-grekas deleted the cache-pdo branch August 19, 2016 16:53
@fabpot fabpot mentioned this pull request Oct 27, 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.

7 participants
0