Added memcached support.
Details
- Reviewers
alex - Commits
- rINP16753: Fixes INP-1750 - Support PHP Memcached extension for caching
Part 1 (general test on PHP5)
- confirm, that Memcached service is installed and started on the server
- restart Memcached service
- re-install In-Portal and on "Step 11 - System Configuration" confirm, that option "Memcached (via "Memcache" extension)" is available choice for "Output Caching Engine" dropdown.
- choose this option.
- login to Administrative Console
- go to Tools → System Tools section
- confirm, that "Memory Cache" sub-section is visible
Part 2 (general test on PHP7)
- confirm, that Memcached service is installed and started on the server
- restart Memcached service
- re-install In-Portal and on "Step 11 - System Configuration" confirm, that option "Memcached (via "Memcached" extension)" is available choice for "Output Caching Engine" dropdown.
- choose this option.
- login to Administrative Console
- go to Tools → System Tools section
- confirm, that "Memory Cache" sub-section is visible
Preparation for following tests
- create /memcache_test.php file with following content:
<?php <?php $start = microtime(true); define('FULL_PATH', realpath(dirname(__FILE__))); include_once(FULL_PATH.'/core/kernel/startup.php'); $application =& kApplication::Instance(); $application->Init(); echo 'PHP ' . PHP_VERSION . '<br/><br/>'; switch ( $application->GetVar('step') ) { case 'delete': echo 'Deleting Infinite Key<br/>' . PHP_EOL; $application->deleteCache('infinite_key'); echo 'Deleting Expiring Key<br/>' . PHP_EOL; $application->deleteCache('expiring_key'); echo 'Deleting Infinite Added Key<br/>' . PHP_EOL; $application->deleteCache('infinite_added_key'); echo 'Deleting Expiring Added Key<br/>' . PHP_EOL; $application->deleteCache('expiring_added_key'); break; case 'set': $result = $application->setCache('infinite_key', 'infinite value'); echo 'Setting Infinite Key: '; var_dump($result); $result = $application->setCache('expiring_key', 'expiring value', 30); echo 'Setting Expiring Key: '; var_dump($result); $result = $application->addCache('infinite_added_key', 'infinite added value'); echo 'Adding Infinite Adding Key: '; var_dump($result); $result = $application->addCache('expiring_added_key', 'expiring added value', 30); echo 'Adding Expiring Adding Key: '; var_dump($result); break; default: echo 'Getting Infinite Key:' . PHP_EOL; var_dump($application->getCache('infinite_key')); echo 'Getting Expiring Key:' . PHP_EOL; var_dump($application->getCache('expiring_key')); echo 'Getting Infinite Added Key:' . PHP_EOL; var_dump($application->getCache('infinite_added_key')); echo 'Getting Expiring Added Key:' . PHP_EOL; var_dump($application->getCache('expiring_added_key')); break; } $end = microtime(true);
- this is URL for showing: .../memcache_test.php?step=show
- this is URL for setting: .../memcache_test.php?step=set
- this is URL for deleting: .../memcache_test.php?step=delete
Part 3 (no cached value by default)
- open showing URL couple of times
- confirm, that output is similar to this:
PHP ... Getting Infinite Key: boolean false Getting Expiring Key: boolean false Getting Infinite Added Key: boolean false Getting Expiring Added Key: boolean false
Part 4 (value is persistent upon setting/adding)
- open setting URL
- confirm, that output is similar to this:
PHP ... Setting Infinite Key: boolean true Setting Expiring Key: boolean true Adding Infinite Adding Key: boolean true Adding Expiring Adding Key: boolean true
- open setting URL
- confirm, that output is similar to this:
PHP ... Setting Infinite Key: boolean true Setting Expiring Key: boolean true Adding Infinite Adding Key: boolean false Adding Expiring Adding Key: boolean false
- open getting URL couple of times
- confirm, that output is similar to this:
PHP ... Getting Infinite Key: string 'infinite value' (length=14) Getting Expiring Key: string 'expiring value' (length=14) Getting Infinite Added Key: string 'infinite added value' (length=20) Getting Expiring Added Key: string 'expiring added value' (length=20)
- wait 35 seconds (because auto-expiration is set to 30 seconds)
- open getting URL couple of times
- confirm, that output is similar to this:
PHP ... Getting Infinite Key: string 'infinite value' (length=14) Getting Expiring Key: boolean false Getting Infinite Added Key: string 'infinite added value' (length=20) Getting Expiring Added Key: boolean false
- open deleting URL
- open showing URL couple of times
- confirm, that output is similar to this:
PHP ... Getting Infinite Key: boolean false Getting Expiring Key: boolean false Getting Infinite Added Key: boolean false Getting Expiring Added Key: boolean false
Diff Detail
- Repository
- rINP In-Portal
- Branch
- /in-portal/branches/5.2.x
- Lint
Lint Errors Excuse: Full file re-formatting is not part of this task. Severity Location Code Message Error core/install/install_toolkit.php:972 PHPCS.E.CodingStandard.Array.Array.SpaceAfterKeyword CodingStandard.Array.Array.SpaceAfterKeyword Error core/install/install_toolkit.php:972 PHPCS.E.Generic.PHP.LowerCaseKeyword.Found Generic.PHP.LowerCaseKeyword.Found Error core/kernel/utility/cache.php:107 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:109 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:111 PHPCS.E.CodingStandard.Commenting.InlineComment.InvalidEndChar CodingStandard.Commenting.InlineComment.InvalidEndChar Error core/kernel/utility/cache.php:111 PHPCS.E.CodingStandard.Commenting.InlineComment.NotCapital CodingStandard.Commenting.InlineComment.NotCapital Error core/kernel/utility/cache.php:830 PHPCS.E.CodingStandard.Classes.ClassDeclaration.OpenBraceNewLine CodingStandard.Classes.ClassDeclaration.OpenBraceNewLine Error core/kernel/utility/cache.php:830 PHPCS.E.CodingStandard.Classes.ClassDeclaration.SpaceBeforeKeyword CodingStandard.Classes.ClassDeclaration.SpaceBeforeKeyword Error core/kernel/utility/cache.php:830 PHPCS.E.Generic.Files.OneClassPerFile.MultipleFound Generic.Files.OneClassPerFile.MultipleFound Error core/kernel/utility/cache.php:830 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:835 PHPCS.E.CodingStandard.Commenting.DocComment.TagValueIndent CodingStandard.Commenting.DocComment.TagValueIndent Error core/kernel/utility/cache.php:838 PHPCS.E.CodingStandard.NamingConventions.ValidVariableName.PublicHasUnderscore CodingStandard.NamingConventions.ValidVariableName.PublicHasUnderscore Error core/kernel/utility/cache.php:838 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:838 PHPCS.E.PEAR.NamingConventions.ValidVariableName.PublicUnderscore PEAR.NamingConventions.ValidVariableName.PublicUnderscore Error core/kernel/utility/cache.php:846 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:854 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:859 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:860 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:864 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:865 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:867 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:870 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:873 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Error core/kernel/utility/cache.php:875 PHPCS.E.Generic.WhiteSpace.ScopeIndent.IncorrectExact Generic.WhiteSpace.ScopeIndent.IncorrectExact Warning core/kernel/utility/cache.php:836 PHPCS.W.Squiz.Commenting.VariableComment.TagNotAllowed Squiz.Commenting.VariableComment.TagNotAllowed - Unit
No Unit Test Coverage - Build Status
Buildable 895 Build 895: arc lint + arc unit
Event Timeline
Test plan requested updates:
- cover auto-usage of Memcached on PHP 7+, when Memcache is configured to be used
- cover usage of new caching backend (all public methods via corresponding kApplication facade methods (e.g. MemcachedCacheHandler::add maps to kApplication::addCache and so on)
I'm not able to test any further, because all data set to cache will auto-expire immediately.
core/install/install_toolkit.php | ||
---|---|---|
973–975 | Please reformat to have one array element on one line. | |
core/kernel/utility/cache.php | ||
107 | Please replace version_compare(PHP_VERSION, '7.0.0', '>=') with PHP_VERSION_ID >= 70000 Works faster. | |
835 | I doubt, that class name used in Memcached PHP extension matches class name used in Memcache PHP extension. | |
905 | Please pass argument according to method signature:
The value of $expiration parameter is ignored. | |
921 | Please pass argument according to method signature:
The value of $expiration parameter is ignored. |
Not reopening, but test plan have issues:
- not tested, that data is actually persistent in Memcache (e.g. available on different page loads)
- not tested, that data in Memcache expires at given moment of time
Fixed API difference causing a notice (and non-working cache), when attempting to get several keys at once using get method.
This change isn't a bug fix request, but a requirement change, that happened over time.
Please also update the test plan.
core/kernel/utility/cache.php | ||
---|---|---|
107–109 |
With CentOS, it's possible to install both PHP extensions (Memcache & Memcached) on any PHP version (even 5.x one). Therefore the assumption of fact, that if it's PHP 7, then the Memcache module is 100% non-available isn't true anymore. |
core/kernel/utility/cache.php | ||
---|---|---|
107–109 | Instead of changing the fallback solution do this:
|
core/kernel/utility/cache.php | ||
---|---|---|
106–111 | Please return this code. When I said delete this fallback code in my previous comment that was meant only to selected code of that inline comment, which was: if ( $handler_class == 'MemcacheCacheHandler' && PHP_VERSION_ID >= 70000 ) { $handler_class = 'MemcachedCacheHandler'; } | |
908 | Please remove. No longer relevant. | |
924 | Please remove. No longer relevant. | |
938 | Please remove the , 0. According to Memcached server documentation this behavior is no longer supported. |
Done requested changes - returned fallback to FakeCacheHandler zero time parameterusage and comments.