From 50bf868066db4a9862ec0f0e72d057ecf4e2236e Mon Sep 17 00:00:00 2001 From: David Strauss Date: Tue, 6 Sep 2016 16:24:23 -0700 Subject: [PATCH 01/82] Initial port. --- .editorconfig | 11 ++ .gitignore | 4 + LICENSE.txt | 339 ++++++++++++++++++++++++++++++++++ README.md | 23 +++ composer.json | 19 ++ lcache.cache.inc | 160 ++++++++++++++++ lcache.info | 4 + lcache.info.yml | 6 + lcache.install | 114 ++++++++++++ lcache.module | 2 + lcache.services.yml | 4 + src/Backend.php | 197 ++++++++++++++++++++ src/BackendFactory.php | 49 +++++ src/Tests/BackendUnitTest.php | 37 ++++ 14 files changed, 969 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 composer.json create mode 100644 lcache.cache.inc create mode 100644 lcache.info create mode 100644 lcache.info.yml create mode 100644 lcache.install create mode 100644 lcache.module create mode 100644 lcache.services.yml create mode 100644 src/Backend.php create mode 100644 src/BackendFactory.php create mode 100644 src/Tests/BackendUnitTest.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2ce2e4f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[{*.inc, *.php}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd38926 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +phpunit.xml +vendor +composer.lock diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8958324 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# LCache + +This module provides a combination L1/L2 cache using a combination +of APCu as L1 with a database as L2 (and for coherency management +among the L1 caches). + +Currently only supported on Pantheon, but there's nothing that +inherently relies on anything Pantheon-specific. + +Upstream library: https://github.com/lcache/lcache + +## Usage + + 1. Upload the module to your site. + 2. Update your Composer dependencies to ensure that the + lcache/lcache module is available to your Drupal site. + See: https://www.drupal.org/node/2514612 + 3. Install the module (so Drupal creates the schema). + 4. Edit settings.php to make LCache the default cache class, for example: + $settings['cache']['default'] = 'cache.backend.lcache'; + 5. Configure write-heavy caches like the form cache to use a backend like + the default database one or another write-friendly cache. + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..88f7b71 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "drupal/lcache", + "description": "LCache module.", + "type": "drupal-module", + "license": "GPLv2", + "authors": [ + { + "name": "David Strauss", + "email": "david@davidstrauss.net" + } + ], + "require": { + "lcache/lcache": "v0.2.*" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "phpunit/dbunit": "*" + } +} diff --git a/lcache.cache.inc b/lcache.cache.inc new file mode 100644 index 0000000..5fc68e4 --- /dev/null +++ b/lcache.cache.inc @@ -0,0 +1,160 @@ + 2, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); + $dbh = new PDO($dsn, $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $options); + $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + return $dbh; +} + +/** + * Defines an L1/L2-based cache implementation. + * + * This cache is based on local APCu data stores and the database. + * Every time a cache item gets updated, we write it to the local cache and the DB. + */ +class LCache implements DrupalCacheInterface { + + /** + * The cache bin. + */ + protected $bin; + + /** + * The integrated L1/L2 cache implementation. + */ + protected $integrated; + + /** + * Constructs an LCache object. + * + * @param $bin + * The cache bin for which the object is created. This will be mostly for the DB cache. + */ + public function __construct($bin=NULL) { + $this->bin = $bin; + + // Use the Null L1 cache for the CLI. + $l1 = new \LCache\NullL1(); + if (php_sapi_name() !== 'cli') { + $l1 = new \LCache\APCuL1(); + } + + $l2 = new \LCache\DatabaseL2(lcache_get_pdo_handle()); + //$l2 = new \LCache\StaticL2(); + + $this->integrated = new \LCache\Integrated($l1, $l2); + //header('LCache-Pool: ' . $this->integrated->getPool()); + } + + protected function getAddress($cid) { + return new \LCache\Address($this->bin, $cid); + } + + /** + * Implements DrupalCacheInterface::get(). + */ + public function get($cid) { + $address = $this->getAddress($cid); + $entry = $this->integrated->getEntry($address); + + if (is_null($entry)) { + return FALSE; + } + + $response = new stdClass(); + $response->cid = $cid; + $response->data = $entry->value; + $response->created = $entry->created; + $response->expire = $entry->expiration; + return $response; + } + + /** + * Implements DrupalCacheInterface::getMultiple(). + */ + public function getMultiple(&$cids) { + if (empty($cids)) return; + $cache = array(); + foreach ($cids as $cid) { + $c = $this->get($cid); + if (!empty($c)) { + $cache[$cid] = $c; + } + } + return $cache; + } + + /** + * Implements DrupalCacheInterface::set(). + */ + public function set($cid, $data, $expire = CACHE_PERMANENT) { + $address = $this->getAddress($cid); + $ttl = NULL; + if ($expire === CACHE_TEMPORARY) { + $ttl = 86400; // @TODO: Use a configurable value. + } + else if ($expire !== CACHE_PERMANENT) { + $ttl = $expire - REQUEST_TIME; + } + $this->integrated->set($address, $data, $ttl); + } + + /** + * Implements DrupalCacheInterface::clear(). + */ + public function clear($cid = NULL, $wildcard = FALSE) { + if (empty($cid)) { + // Flush expired, temporary cache entries now. + $this->integrated->collectGarbage(); + } + else { + if ($wildcard) { + $address = $this->getAddress(); + $this->integrated->delete($address); + } + elseif (is_array($cid)) { + foreach ($cid as $cid_entry) { + $address = $this->getAddress($cid); + $this->integrated->delete($address); + } + } + else { + $address = $this->getAddress($cid); + $this->integrated->delete($address); + } + } + } + + /** + * Implements DrupalCacheInterface::isEmpty(). + */ + public function isEmpty() { + return FALSE; + } + + /** + * Garbage collection for get() and getMultiple(). + * + * @param $bin + * The bin being requested. + */ + protected function garbageCollection() { + } + + public function synchronize() { + $this->integrated->synchronize(); + } +} + +$lcache = new LCache(); +$applied = $lcache->synchronize(); +header('LCache-Changes-Applied: ' . $applied ? $applied : 'NULL'); diff --git a/lcache.info b/lcache.info new file mode 100644 index 0000000..3a721ef --- /dev/null +++ b/lcache.info @@ -0,0 +1,4 @@ +name = "LCache" +description = "Provides a cache using APCu and the database." +package = Performance +core = 7.x diff --git a/lcache.info.yml b/lcache.info.yml new file mode 100644 index 0000000..9db3686 --- /dev/null +++ b/lcache.info.yml @@ -0,0 +1,6 @@ +name: LCache +description: 'Tiered caching.' +type: module +package: 'Performance and scalability' +core: 8.x + diff --git a/lcache.install b/lcache.install new file mode 100644 index 0000000..e270add --- /dev/null +++ b/lcache.install @@ -0,0 +1,114 @@ + 'Stores a stream of cache changes for coherency management.', + 'fields' => array( + 'event_id' => array( + 'description' => 'Primary Key: Event ID.', + 'type' => 'serial', + 'not null' => TRUE, + ), + 'pool' => array( + 'description' => 'PHP process pool that wrote the change.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'address' => array( + 'description' => 'Cache entry address (bin and key).', + 'type' => 'varchar_ascii', + 'length' => 255, + 'not null' => FALSE, + 'default' => NULL, + ), + 'value' => array( + 'description' => 'Cache entry value.', + 'type' => 'blob', + 'not null' => FALSE, + 'size' => 'big', + ), + 'expiration' => array( + 'description' => 'A Unix timestamp indicating when the cache entry should expire, or NULL for never.', + 'type' => 'int', + 'not null' => FALSE, + 'default' => NULL, + ), + 'created' => array( + 'description' => 'A Unix timestamp indicating when the cache entry was created.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'indexes' => array( + 'expiration' => array('expiration'), + 'lookup_miss' => array('address', 'event_id'), + ), + 'primary key' => array('event_id'), + ); + $schema['lcache_tags'] = array( + 'description' => 'Stores mappings from tags to cache items.', + 'fields' => array( + 'tag' => array( + 'description' => 'Cache tag.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + 'default' => NULL, + ), + 'event_id' => array( + 'description' => 'The event_id associated with the cache entry.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'indexes' => array( + 'rewritten_entry' => array('event_id'), + ), + 'primary key' => array('tag', 'event_id'), + 'foreign keys' => array( + 'lcache_events_event_id' => array( + 'table' => 'lcache_events', + 'columns' => array('event_id' => 'event_id'), + ), + ), + ); + + return $schema; +} + +/** + * Implements hook_install(). + */ +function lcache_install() { + db_query(' + ALTER TABLE {lcache_tags} + ADD CONSTRAINT {lcache_tags_event_id} + FOREIGN KEY (event_id) REFERENCES {lcache_events} (event_id) + '); +} + +/** + * Implements hook_uninstall(). + */ +function lcache_uninstall() { + db_query(' + ALTER TABLE {lcache_tags} + DROP FOREIGN KEY IF EXISTS {lcache_tags_event_id} + '); +} + diff --git a/lcache.module b/lcache.module new file mode 100644 index 0000000..a4abe2d --- /dev/null +++ b/lcache.module @@ -0,0 +1,2 @@ +bin = $bin; + $this->integrated = $integrated; + } + + protected function getAddress($cid) { + return new \LCache\Address($this->bin, $cid); + } + + /** + * {@inheritdoc} + */ + public function get($cid, $allow_invalid = FALSE) { + $address = $this->getAddress($cid); + $entry = $this->integrated->getEntry($address); + + if (is_null($entry)) { + return FALSE; + } + + $response = new \stdClass(); + $response->cid = $cid; + $response->data = $entry->value; + $response->created = $entry->created; + $response->expire = $entry->expiration; + return $response; + } + + /** + * {@inheritdoc} + */ + public function getMultiple(&$cids, $allow_invalid = FALSE) { + if (empty($cids)) return; + $cache = array(); + foreach ($cids as $cid) { + $c = $this->get($cid); + if (!empty($c)) { + $cache[$cid] = $c; + } + } + return $cache; + } + + /** + * {@inheritdoc} + */ + public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { + assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)'); + $tags = array_unique($tags); + // Sort the cache tags so that they are stored consistently. + sort($tags); + + $address = $this->getAddress($cid); + $ttl = NULL; + if ($expire !== CacheBackendInterface::CACHE_PERMANENT) { + $ttl = $expire - REQUEST_TIME; + } + $this->integrated->set($address, $data, $ttl, $tags); + } + + /** + * {@inheritdoc} + */ + public function setMultiple(array $items) { + foreach ($items as $cid => $item) { + $item += array( + 'expire' => CacheBackendInterface::CACHE_PERMANENT, + 'tags' => array(), + ); + $this->set($cid, $item['data'], $item['expire'], $item['tags']); + } + } + + /** + * {@inheritdoc} + */ + public function delete($cid) { + $address = $this->getAddress($cid); + $this->integrated->delete($address); + } + + /** + * {@inheritdoc} + */ + public function deleteMultiple(array $cids) { + foreach ($cids as $cid) { + $this->delete($cid); + } + } + + /** + * {@inheritdoc} + */ + public function deleteAll() { + $this->delete(NULL); + } + + /** + * {@inheritdoc} + */ + public function invalidate($cid) { + $this->delete($cid); + } + + /** + * Marks cache items as invalid. + * + * Invalid items may be returned in later calls to get(), if the + * $allow_invalid argument is TRUE. + * + * @param array $cids + * An array of cache IDs to invalidate. + * + * @see Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() + * @see Drupal\Core\Cache\CacheBackendInterface::invalidate() + * @see Drupal\Core\Cache\CacheBackendInterface::invalidateTags() + * @see Drupal\Core\Cache\CacheBackendInterface::invalidateAll() + */ + public function invalidateMultiple(array $cids) { + foreach ($cids as $cid) { + $this->invalidate($cid); + } + } + + /** + * {@inheritdoc} + */ + public function invalidateAll() { + $this->delete(NULL); + } + + /** + * {@inheritdoc} + */ + public function invalidateTags(array $tags) { + foreach ($tags as $tag) { + $this->integrated->deleteTag($tag); + } + } + + /** + * {@inheritdoc} + */ + public function removeBin() { + $this->invalidateAll(); + } + + /** + * {@inheritdoc} + */ + public function garbageCollection() { + $this->integrated->collectGarbage(); + } + + /** + * (@inheritdoc) + */ + public function isEmpty() { + return FALSE; + } +} diff --git a/src/BackendFactory.php b/src/BackendFactory.php new file mode 100644 index 0000000..7d8e489 --- /dev/null +++ b/src/BackendFactory.php @@ -0,0 +1,49 @@ + 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); + $dbh = new \PDO($dsn, $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $options); + $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + return $dbh; + } + + /** + * Constructs the BackendFactory object. + */ + public function __construct() { + // Use the Null L1 cache for the CLI. + $l1 = new \LCache\NullL1(); + if (php_sapi_name() !== 'cli') { + $l1 = new \LCache\APCuL1(); + } + $l2 = new \LCache\DatabaseL2($this->get_pdo_handle()); + $this->integrated = new \LCache\Integrated($l1, $l2); + $this->integrated->synchronize(); + } + + /** + * Gets an LCache Backend for the specified cache bin. + * + * @param $bin + * The cache bin for which the object is created. + * + * @return \Drupal\lcache\Backend + * The cache backend object for the specified cache bin. + */ + public function get($bin) { + return new Backend($bin, $this->integrated); + } +} diff --git a/src/Tests/BackendUnitTest.php b/src/Tests/BackendUnitTest.php new file mode 100644 index 0000000..937a00d --- /dev/null +++ b/src/Tests/BackendUnitTest.php @@ -0,0 +1,37 @@ +get($bin); + } +} From 1b81f310635439ef37a4bd97de08d4bb68de05b9 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 07:49:36 -0500 Subject: [PATCH 02/82] Remove database constraint --- lcache.install | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lcache.install b/lcache.install index e270add..983596d 100644 --- a/lcache.install +++ b/lcache.install @@ -91,17 +91,6 @@ function lcache_schema() { return $schema; } -/** - * Implements hook_install(). - */ -function lcache_install() { - db_query(' - ALTER TABLE {lcache_tags} - ADD CONSTRAINT {lcache_tags_event_id} - FOREIGN KEY (event_id) REFERENCES {lcache_events} (event_id) - '); -} - /** * Implements hook_uninstall(). */ From d742d0b444572ddc18a81aed4f69ef3a34f7d806 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:11:30 -0500 Subject: [PATCH 03/82] Starting on CircleCI integration --- circle.yml | 39 ++++++++++++++++++++ tests/circle-scripts/create-fresh-d8-site.sh | 11 ++++++ tests/circle-scripts/setup-d8-repo.sh | 31 ++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 circle.yml create mode 100644 tests/circle-scripts/create-fresh-d8-site.sh create mode 100644 tests/circle-scripts/setup-d8-repo.sh diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..9743b9c --- /dev/null +++ b/circle.yml @@ -0,0 +1,39 @@ +# https://circleci.com/docs/configuration#machine +machine: + php: + # https://circleci.com/docs/environment#php + version: 7.0.7 + environment: + # DB config. Using default CircleCI's database. + TERMINUS_ENV: ci-$CIRCLE_BUILD_NUM + TERMINUS_SITE: d8lcache + PATH: $PATH:~/drupal-8/vendor/bin + +dependencies: + cache_directories: + - ~/.composer/cache + pre: + # Set the PHP timezone so that Behat script does not fail. + # Using > instead of >> will overwrite the file and disable xdebug. + # xdebug makes composer slower. + - echo "date.timezone = 'US/Central'" > /opt/circleci/php/7.0.7/etc/conf.d/xdebug.ini + override: + - composer global require "hirak/prestissimo:^0.3" + - composer global require pantheon-systems/terminus + - composer global require drush/drush:8.* + - composer install + post: + - terminus auth login --machine-token=$TERMINUS_TOKEN +test: + pre: + #- ./vendor/bin/phpcs --report=full --extensions=php,module,inc,theme,info,install --standard=vendor/drupal/coder/coder_sniffer/Drupal . --ignore=vendor,modules,core,drush,patches,tests + # Make a new multidev env from a vanilla D8 site. + - cd tests/circle-scripts && ./create-fresh-d8-site.sh + # # Set up the D8 site with contrib migrate contrib modules and enable + # # those modules on Panetheon. + - cd tests/circle-scripts && ./setup-d8-repo.sh + # + # # Configure the migration, creating exportable, re-runnable configuration. + # - cd tests/circle-scripts && ./enable-modules.sh + # override: + # - cd tests/circle-scripts && ./run-tests.sh diff --git a/tests/circle-scripts/create-fresh-d8-site.sh b/tests/circle-scripts/create-fresh-d8-site.sh new file mode 100644 index 0000000..eeb9297 --- /dev/null +++ b/tests/circle-scripts/create-fresh-d8-site.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# @todo, pull in upstream updates, wipe and install drupal. +# Also, it might be cleaner to create an entirely new D8 site rather than making +# multidevs off of the same one repeatedly. +terminus site create-env --to-env=$TERMINUS_ENV --from-env=dev + +# @todo, this command gives an error +# [error] You must upgrade to a business or an elite plan to use Solr. +# Bug tracked here: https://github.com/pantheon-systems/terminus/issues/1118 +#terminus site solr enable diff --git a/tests/circle-scripts/setup-d8-repo.sh b/tests/circle-scripts/setup-d8-repo.sh new file mode 100644 index 0000000..a6ab469 --- /dev/null +++ b/tests/circle-scripts/setup-d8-repo.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Bring the code down to Circle so that modules can be added via composer. +git clone $(terminus site connection-info --field=git_url) $TERMINUS_SITE +cd $TERMINUS_SITE +git checkout $TERMINUS_ENV + +#composer config repositories.drupal composer https://packages.drupal.org/8 +composer config repositories.d8lcache vcs git@github.com:lcache/drupal-8.git +composer require drupal/lcache:dev-master#$CIRCLE_SHA1 + +# Make sure submodules are not committed. +rm -rf modules/lcache/.git/ +# Make a git commit +git add . +git commit -m 'Result of build step' +git push --set-upstream origin $TERMINUS_ENV + +# Instal Drupal and Enable LCache. +{ + terminus drush "si -y" +} &> /dev/null +terminus drush "en lcache -y" + +# Set LCache to be the default cache service. + +echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php + +git add . +git commit -m 'LCache in settings.php' +git push origin $TERMINUS_ENV From 1177aa67d99feb9c67eb563b17f1898c74b63010 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:19:44 -0500 Subject: [PATCH 04/82] Update circle.yml --- circle.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/circle.yml b/circle.yml index 9743b9c..bddf06d 100644 --- a/circle.yml +++ b/circle.yml @@ -4,7 +4,6 @@ machine: # https://circleci.com/docs/environment#php version: 7.0.7 environment: - # DB config. Using default CircleCI's database. TERMINUS_ENV: ci-$CIRCLE_BUILD_NUM TERMINUS_SITE: d8lcache PATH: $PATH:~/drupal-8/vendor/bin From f6b3670e40d17ddfe5130918d102a53c0cfec413 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:20:53 -0500 Subject: [PATCH 05/82] Update circle.yml --- circle.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/circle.yml b/circle.yml index bddf06d..085a631 100644 --- a/circle.yml +++ b/circle.yml @@ -28,11 +28,8 @@ test: #- ./vendor/bin/phpcs --report=full --extensions=php,module,inc,theme,info,install --standard=vendor/drupal/coder/coder_sniffer/Drupal . --ignore=vendor,modules,core,drush,patches,tests # Make a new multidev env from a vanilla D8 site. - cd tests/circle-scripts && ./create-fresh-d8-site.sh - # # Set up the D8 site with contrib migrate contrib modules and enable - # # those modules on Panetheon. - cd tests/circle-scripts && ./setup-d8-repo.sh # - # # Configure the migration, creating exportable, re-runnable configuration. # - cd tests/circle-scripts && ./enable-modules.sh # override: # - cd tests/circle-scripts && ./run-tests.sh From a67e30438bb9664f32a4581c7a701ec2d6d1243c Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:23:21 -0500 Subject: [PATCH 06/82] Update circle.yml --- circle.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/circle.yml b/circle.yml index 085a631..3d718a0 100644 --- a/circle.yml +++ b/circle.yml @@ -6,7 +6,6 @@ machine: environment: TERMINUS_ENV: ci-$CIRCLE_BUILD_NUM TERMINUS_SITE: d8lcache - PATH: $PATH:~/drupal-8/vendor/bin dependencies: cache_directories: From 831ef427c12f8648140cc9599e2c00a265fea96f Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:26:24 -0500 Subject: [PATCH 07/82] executable --- tests/circle-scripts/create-fresh-d8-site.sh | 0 tests/circle-scripts/setup-d8-repo.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/circle-scripts/create-fresh-d8-site.sh mode change 100644 => 100755 tests/circle-scripts/setup-d8-repo.sh diff --git a/tests/circle-scripts/create-fresh-d8-site.sh b/tests/circle-scripts/create-fresh-d8-site.sh old mode 100644 new mode 100755 diff --git a/tests/circle-scripts/setup-d8-repo.sh b/tests/circle-scripts/setup-d8-repo.sh old mode 100644 new mode 100755 From e4bbab7c74e0bd4cdf02f1035ac42a338dcf8438 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:34:02 -0500 Subject: [PATCH 08/82] Update circle.yml --- circle.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/circle.yml b/circle.yml index 3d718a0..80feecf 100644 --- a/circle.yml +++ b/circle.yml @@ -15,6 +15,8 @@ dependencies: # Using > instead of >> will overwrite the file and disable xdebug. # xdebug makes composer slower. - echo "date.timezone = 'US/Central'" > /opt/circleci/php/7.0.7/etc/conf.d/xdebug.ini + - git config --global user.email "noreply@pantheon.io" + - git config --global user.name "Circle CI" override: - composer global require "hirak/prestissimo:^0.3" - composer global require pantheon-systems/terminus From e0fb67e39f09cbfcb1a09c4eb3e9d7d57b24863c Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:38:52 -0500 Subject: [PATCH 09/82] Adding behat dir --- tests/behat/behat-pantheon.yml | 28 ++++++++++++++++++++++++ tests/behat/features/node-saving.feature | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 tests/behat/behat-pantheon.yml create mode 100644 tests/behat/features/node-saving.feature diff --git a/tests/behat/behat-pantheon.yml b/tests/behat/behat-pantheon.yml new file mode 100644 index 0000000..f7f9f15 --- /dev/null +++ b/tests/behat/behat-pantheon.yml @@ -0,0 +1,28 @@ +# +# behat.yml file for testing with a Drupal site on Pantheon. +# +default: + suites: + default: + paths: + - %paths.base%/features + - %paths.base%/common-features + contexts: + #- FeatureContext + - Drupal\DrupalExtension\Context\DrupalContext + - Drupal\DrupalExtension\Context\DrushContext + - Drupal\DrupalExtension\Context\MinkContext + - scripted_php7_profiling\Behat\PerformanceHelpers + extensions: + Behat\MinkExtension: + goutte: ~ + selenium2: ~ + files_path: './data-files' +# Supplied by env variable. +# base_url: http://dev-persch-d8-solr.pantheonsite.io/ + Drupal\DrupalExtension: + blackbox: ~ + api_driver: 'drush' + drush: +# Supplied by env variable. +# alias: '@pantheon.persch-d8-solr.dev' diff --git a/tests/behat/features/node-saving.feature b/tests/behat/features/node-saving.feature new file mode 100644 index 0000000..5cbe635 --- /dev/null +++ b/tests/behat/features/node-saving.feature @@ -0,0 +1,4 @@ +Feature: Node saving + + @api + Scenario: Node Saving From 151b4dd8bc341816afce1995786bd580d871d5ca Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:39:32 -0500 Subject: [PATCH 10/82] Adding behat to composer --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 88f7b71..dbb5f15 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,9 @@ }, "require-dev": { "phpunit/phpunit": "4.*", - "phpunit/dbunit": "*" + "phpunit/dbunit": "*", + "drush-ops/behat-drush-endpoint": "*", + "drupal/drupal-extension": "dev-master", + "drupal/drupal-driver": "dev-master" } } From ad4debe7442334061cf19eaa9fdaca829edc0600 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:41:16 -0500 Subject: [PATCH 11/82] adding gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59c71e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/vendor +/drush + From 7eb48f49ce2d78f7e792f6986206d2bbd296e135 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:43:06 -0500 Subject: [PATCH 12/82] Core vs. LCache --- circle.yml | 2 +- tests/circle-scripts/{setup-d8-repo.sh => core-vs-lcache.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/circle-scripts/{setup-d8-repo.sh => core-vs-lcache.sh} (100%) diff --git a/circle.yml b/circle.yml index 80feecf..07bb479 100644 --- a/circle.yml +++ b/circle.yml @@ -29,7 +29,7 @@ test: #- ./vendor/bin/phpcs --report=full --extensions=php,module,inc,theme,info,install --standard=vendor/drupal/coder/coder_sniffer/Drupal . --ignore=vendor,modules,core,drush,patches,tests # Make a new multidev env from a vanilla D8 site. - cd tests/circle-scripts && ./create-fresh-d8-site.sh - - cd tests/circle-scripts && ./setup-d8-repo.sh + - cd tests/circle-scripts && ./core-vs-lcache.sh # # - cd tests/circle-scripts && ./enable-modules.sh # override: diff --git a/tests/circle-scripts/setup-d8-repo.sh b/tests/circle-scripts/core-vs-lcache.sh similarity index 100% rename from tests/circle-scripts/setup-d8-repo.sh rename to tests/circle-scripts/core-vs-lcache.sh From 324b20d8d2471676e73dc8a89827dd0183f08c61 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:48:19 -0500 Subject: [PATCH 13/82] changing script names --- circle.yml | 1 + tests/behat/features/node-saving.feature | 1 + tests/circle-scripts/clone-repo.sh | 5 ++ tests/circle-scripts/core-vs-lcache.sh | 62 +++++++++++++++++++----- 4 files changed, 56 insertions(+), 13 deletions(-) create mode 100755 tests/circle-scripts/clone-repo.sh diff --git a/circle.yml b/circle.yml index 07bb479..d1b7f05 100644 --- a/circle.yml +++ b/circle.yml @@ -29,6 +29,7 @@ test: #- ./vendor/bin/phpcs --report=full --extensions=php,module,inc,theme,info,install --standard=vendor/drupal/coder/coder_sniffer/Drupal . --ignore=vendor,modules,core,drush,patches,tests # Make a new multidev env from a vanilla D8 site. - cd tests/circle-scripts && ./create-fresh-d8-site.sh + - cd tests/circle-scripts && ./clone-repo.sh - cd tests/circle-scripts && ./core-vs-lcache.sh # # - cd tests/circle-scripts && ./enable-modules.sh diff --git a/tests/behat/features/node-saving.feature b/tests/behat/features/node-saving.feature index 5cbe635..2167283 100644 --- a/tests/behat/features/node-saving.feature +++ b/tests/behat/features/node-saving.feature @@ -2,3 +2,4 @@ Feature: Node saving @api Scenario: Node Saving + Given I am logged in as a user with the "administrator" role diff --git a/tests/circle-scripts/clone-repo.sh b/tests/circle-scripts/clone-repo.sh new file mode 100755 index 0000000..92c8301 --- /dev/null +++ b/tests/circle-scripts/clone-repo.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +git clone $(terminus site connection-info --field=git_url) $TERMINUS_SITE +cd $TERMINUS_SITE +git checkout $TERMINUS_ENV diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index a6ab469..21c7c2c 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -1,31 +1,67 @@ #!/bin/bash -# Bring the code down to Circle so that modules can be added via composer. -git clone $(terminus site connection-info --field=git_url) $TERMINUS_SITE -cd $TERMINUS_SITE -git checkout $TERMINUS_ENV +set -ex + + +# Create a drush alias file so that Behat tests can be executed against Pantheon. +terminus sites aliases +# Drush Behat driver fails without this option. +echo "\$options['strict'] = 0;" >> ~/.drush/pantheon.aliases.drushrc.php + +export BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "http://'$TERMINUS_ENV'-'$TERMINUS_SITE'.pantheonsite.io/"}, "Drupal\\DrupalExtension" : {"drush" : { "alias": "@pantheon.'$TERMINUS_SITE'.'$TERMINUS_ENV'" }}}}' + +terminus site set-connection-mode --mode=git + + +cd ${TERMINUS_SITE} +git checkout master +git branch -D $TERMINUS_ENV +git pull +git checkout -b $TERMINUS_ENV + + +echo "php_version: 7.0 " >> pantheon.yml + +git add pantheon.yml +git commit -m 'Clean install of Drupal Core' +git push --set-upstream origin $TERMINUS_ENV -f + +sleep 30 +{ + terminus drush "si -y" +} &> /dev/null +terminus site clear-cache + +cd .. +./../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ + + +cd ${TERMINUS_SITE} +sleep 15 #composer config repositories.drupal composer https://packages.drupal.org/8 composer config repositories.d8lcache vcs git@github.com:lcache/drupal-8.git composer require drupal/lcache:dev-master#$CIRCLE_SHA1 -# Make sure submodules are not committed. -rm -rf modules/lcache/.git/ -# Make a git commit +# A .git directory might in modules/lcache/ +git add modules/lcache/* git add . -git commit -m 'Result of build step' -git push --set-upstream origin $TERMINUS_ENV +git commit -m 'Adding LCache' +git push -# Instal Drupal and Enable LCache. +sleep 60 { terminus drush "si -y" } &> /dev/null terminus drush "en lcache -y" - -# Set LCache to be the default cache service. +terminus site clear-cache echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php - git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV + +./../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ + + +terminus site clear-cache From 827e94811fc24e0df0bf4e2954a6429c1f0ae730 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:55:03 -0500 Subject: [PATCH 14/82] no setting of php version --- tests/circle-scripts/core-vs-lcache.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 21c7c2c..3a7f7d2 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -12,7 +12,6 @@ export BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "ht terminus site set-connection-mode --mode=git - cd ${TERMINUS_SITE} git checkout master git branch -D $TERMINUS_ENV @@ -20,8 +19,6 @@ git pull git checkout -b $TERMINUS_ENV -echo "php_version: 7.0 " >> pantheon.yml - git add pantheon.yml git commit -m 'Clean install of Drupal Core' git push --set-upstream origin $TERMINUS_ENV -f From 45bf36868bd7de2ae11cc94c68507f26c45eab6a Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 16:58:38 -0500 Subject: [PATCH 15/82] Going back to php version setting --- tests/circle-scripts/core-vs-lcache.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 3a7f7d2..5d52880 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -12,12 +12,14 @@ export BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "ht terminus site set-connection-mode --mode=git + cd ${TERMINUS_SITE} git checkout master git branch -D $TERMINUS_ENV git pull git checkout -b $TERMINUS_ENV +echo "php_version: 7.0 " >> pantheon.yml git add pantheon.yml git commit -m 'Clean install of Drupal Core' From ca1a710cdf35e4eac41f699bf96b57b8c950dd08 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:05:09 -0500 Subject: [PATCH 16/82] removing unused context --- tests/behat/behat-pantheon.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/behat/behat-pantheon.yml b/tests/behat/behat-pantheon.yml index f7f9f15..e5d9280 100644 --- a/tests/behat/behat-pantheon.yml +++ b/tests/behat/behat-pantheon.yml @@ -12,7 +12,6 @@ default: - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\DrushContext - Drupal\DrupalExtension\Context\MinkContext - - scripted_php7_profiling\Behat\PerformanceHelpers extensions: Behat\MinkExtension: goutte: ~ From b1fc9c40bb17e53b5315cbfc6c368c54f20f512d Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:14:52 -0500 Subject: [PATCH 17/82] Directory changing --- tests/circle-scripts/core-vs-lcache.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 5d52880..06b7df4 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -31,12 +31,10 @@ sleep 30 } &> /dev/null terminus site clear-cache -cd .. -./../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ +./../../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ +sleep 15 -cd ${TERMINUS_SITE} -sleep 15 #composer config repositories.drupal composer https://packages.drupal.org/8 composer config repositories.d8lcache vcs git@github.com:lcache/drupal-8.git @@ -60,7 +58,7 @@ git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV -./../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ +./../../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ terminus site clear-cache From 0adbaa555dc99a9a9e08767a9a9d05c52a5a4b2c Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:18:22 -0500 Subject: [PATCH 18/82] Test saving a node visiting home page --- tests/behat/features/node-saving.feature | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/behat/features/node-saving.feature b/tests/behat/features/node-saving.feature index 2167283..95c3339 100644 --- a/tests/behat/features/node-saving.feature +++ b/tests/behat/features/node-saving.feature @@ -3,3 +3,9 @@ Feature: Node saving @api Scenario: Node Saving Given I am logged in as a user with the "administrator" role + And I visit "/" + When I visit "node/add/article" + And I fill in "title[0][value]" with "First Test Article" + And I press the "Save and publish" button + And I visit "/" + Then I see the text "First Test Article" From 9c03a2025008621032e7e002fe0ec5f325e3de9e Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:24:48 -0500 Subject: [PATCH 19/82] dir fix --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 06b7df4..84a49a7 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -31,7 +31,7 @@ sleep 30 } &> /dev/null terminus site clear-cache -./../../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ +./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ sleep 15 @@ -58,7 +58,7 @@ git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV -./../../../vendor/bin/behat --config=../behat/behat-pantheon.yml ../behat/features/ +./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ terminus site clear-cache From a583bea3f6189443cc1e719ce099bfae9ea8647b Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:42:01 -0500 Subject: [PATCH 20/82] [ci skip] --- tests/circle-scripts/create-fresh-d8-site.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/circle-scripts/create-fresh-d8-site.sh b/tests/circle-scripts/create-fresh-d8-site.sh index eeb9297..c213e77 100755 --- a/tests/circle-scripts/create-fresh-d8-site.sh +++ b/tests/circle-scripts/create-fresh-d8-site.sh @@ -4,8 +4,3 @@ # Also, it might be cleaner to create an entirely new D8 site rather than making # multidevs off of the same one repeatedly. terminus site create-env --to-env=$TERMINUS_ENV --from-env=dev - -# @todo, this command gives an error -# [error] You must upgrade to a business or an elite plan to use Solr. -# Bug tracked here: https://github.com/pantheon-systems/terminus/issues/1118 -#terminus site solr enable From d4f934e73951cda97725e51ac5d112a81ec14d04 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 9 Sep 2016 17:52:01 -0500 Subject: [PATCH 21/82] bumping column size. Not sure if this is involved in the problem. --- lcache.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lcache.install b/lcache.install index 983596d..94c0b08 100644 --- a/lcache.install +++ b/lcache.install @@ -30,7 +30,7 @@ function lcache_schema() { 'address' => array( 'description' => 'Cache entry address (bin and key).', 'type' => 'varchar_ascii', - 'length' => 255, + 'length' => 2056, 'not null' => FALSE, 'default' => NULL, ), From 601173d0afac68a8a315852b9deaca4c2cf0e937 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Sat, 10 Sep 2016 10:10:16 -0500 Subject: [PATCH 22/82] Update lcache.install --- lcache.install | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lcache.install b/lcache.install index 94c0b08..b9b5bf2 100644 --- a/lcache.install +++ b/lcache.install @@ -91,6 +91,20 @@ function lcache_schema() { return $schema; } + +/** + * Implements hook_install(). + */ +function lcache_install() { + db_query(' + ALTER TABLE {lcache_tags} + ADD CONSTRAINT {lcache_tags_event_id} + FOREIGN KEY (event_id) REFERENCES {lcache_events} (event_id) + ON DELETE CASCADE + '); +} + + /** * Implements hook_uninstall(). */ From d0a965706d10340ce566d478bb994674ed779e47 Mon Sep 17 00:00:00 2001 From: David Strauss Date: Mon, 12 Sep 2016 12:40:26 -0700 Subject: [PATCH 23/82] Use LCache v0.3 series with machine learning. --- composer.json | 2 +- src/BackendFactory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 88f7b71..ca19854 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "lcache/lcache": "v0.2.*" + "lcache/lcache": "v0.3.*" }, "require-dev": { "phpunit/phpunit": "4.*", diff --git a/src/BackendFactory.php b/src/BackendFactory.php index 7d8e489..f6d8fc5 100644 --- a/src/BackendFactory.php +++ b/src/BackendFactory.php @@ -30,7 +30,7 @@ public function __construct() { $l1 = new \LCache\APCuL1(); } $l2 = new \LCache\DatabaseL2($this->get_pdo_handle()); - $this->integrated = new \LCache\Integrated($l1, $l2); + $this->integrated = new \LCache\Integrated($l1, $l2, 100); $this->integrated->synchronize(); } From 93fbf78e7efcc5f0a31222a1095f0b7f9286ad79 Mon Sep 17 00:00:00 2001 From: David Strauss Date: Mon, 12 Sep 2016 12:42:38 -0700 Subject: [PATCH 24/82] Cache tags should DELETE CASCADE on event deletion. --- lcache.install | 1 + 1 file changed, 1 insertion(+) diff --git a/lcache.install b/lcache.install index e270add..8f994d1 100644 --- a/lcache.install +++ b/lcache.install @@ -99,6 +99,7 @@ function lcache_install() { ALTER TABLE {lcache_tags} ADD CONSTRAINT {lcache_tags_event_id} FOREIGN KEY (event_id) REFERENCES {lcache_events} (event_id) + ON DELETE CASCADE '); } From 823dfa1c830b3d36189b2708f64da4be43d0dac8 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Mon, 12 Sep 2016 18:48:04 -0500 Subject: [PATCH 25/82] Adding invalidator --- lcache.services.yml | 6 ++ src/BackendInvalidator.php | 117 +++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 src/BackendInvalidator.php diff --git a/lcache.services.yml b/lcache.services.yml index 6ea8056..9bacd81 100644 --- a/lcache.services.yml +++ b/lcache.services.yml @@ -2,3 +2,9 @@ services: cache.backend.lcache: class: Drupal\lcache\BackendFactory arguments: [] + + cache_tags.invalidator.lcache: + class: Drupal\lcache\BackendInvalidator + arguments: ['@database'] + tags: + - { name: cache_tags_invalidator} diff --git a/src/BackendInvalidator.php b/src/BackendInvalidator.php new file mode 100644 index 0000000..2788ff0 --- /dev/null +++ b/src/BackendInvalidator.php @@ -0,0 +1,117 @@ +getConnectionOptions(); + + + + + // @TODO: Use Drupal's connection arguments or actually pull Drupal's PDO handle. + $dsn = 'mysql:host='. $db_info['host']. ';port='. $db_info['port'] .';dbname='. $db_info['database']; + $options = array(\PDO::ATTR_TIMEOUT => 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); + $dbh = new \PDO($dsn, $db_info['username'], $db_info['password'], $options); + $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + return $dbh; + } + + /** + * Constructs the BackendFactory object. + */ + public function __construct(Connection $connection) { + + + $this->connection = $connection; + $this->checksumProvider = $checksum_provider; + + // Use the Null L1 cache for the CLI. + $l1 = new \LCache\NullL1(); + if (php_sapi_name() !== 'cli') { + $l1 = new \LCache\APCuL1(); + } + $l2 = new \LCache\DatabaseL2($this->get_pdo_handle()); + $this->integrated = new \LCache\Integrated($l1, $l2); + $this->integrated->synchronize(); + } + + + + + /** + * {@inheritdoc} + */ + public function invalidateTags(array $tags) { + + + + $txt .= "tags \n"; + $txt .= print_r($tags, 1); + + $myfile = file_put_contents('/tmp/lcache_invalidate.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX); + + + foreach ($tags as $tag) { + + + + + + + + + +// if ($this->bin === 'cache_dynamic_page_cache') { + + + // } + + + + + + + + + + + + + $this->integrated->deleteTag($tag); + } + } + +} From a79cc9adef0dbeb9fa1239112add091e3e805c7c Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 09:18:00 -0500 Subject: [PATCH 26/82] Cleaning up services --- lcache.services.yml | 8 ++-- src/BackendFactory.php | 24 +++++++++-- src/BackendInvalidator.php | 88 +------------------------------------- 3 files changed, 27 insertions(+), 93 deletions(-) diff --git a/lcache.services.yml b/lcache.services.yml index 9bacd81..4380cd2 100644 --- a/lcache.services.yml +++ b/lcache.services.yml @@ -1,10 +1,12 @@ services: cache.backend.lcache: class: Drupal\lcache\BackendFactory - arguments: [] - + arguments: ['@database'] + lcache.integrated: + class: LCache\Integrated + factory: cache.backend.lcache:getIntegratedLCache cache_tags.invalidator.lcache: class: Drupal\lcache\BackendInvalidator - arguments: ['@database'] + arguments: ['@lcache.integrated'] tags: - { name: cache_tags_invalidator} diff --git a/src/BackendFactory.php b/src/BackendFactory.php index 7d8e489..a35b1d7 100644 --- a/src/BackendFactory.php +++ b/src/BackendFactory.php @@ -7,15 +7,17 @@ namespace Drupal\lcache; +use Drupal\Core\Database\Connection; + class BackendFactory { protected $integrated; protected function get_pdo_handle() { - // @TODO: Use Drupal's connection arguments or actually pull Drupal's PDO handle. - $dsn = 'mysql:host='. $_ENV['DB_HOST']. ';port='. $_ENV['DB_PORT'] .';dbname='. $_ENV['DB_NAME']; + $db_info = $this->connection->getConnectionOptions(); + $dsn = 'mysql:host='. $db_info['host']. ';port='. $db_info['port'] .';dbname='. $db_info['database']; $options = array(\PDO::ATTR_TIMEOUT => 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); - $dbh = new \PDO($dsn, $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $options); + $dbh = new \PDO($dsn, $db_info['username'], $db_info['password'], $options); $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $dbh; } @@ -23,7 +25,10 @@ protected function get_pdo_handle() { /** * Constructs the BackendFactory object. */ - public function __construct() { + public function __construct(Connection $connection) { + + $this->connection = $connection; + // Use the Null L1 cache for the CLI. $l1 = new \LCache\NullL1(); if (php_sapi_name() !== 'cli') { @@ -46,4 +51,15 @@ public function __construct() { public function get($bin) { return new Backend($bin, $this->integrated); } + + /** + * Gets an LCache Backend for the specified cache bin. + * + * @return \LCache\Integrated + * The integrated cache backend. + */ + public function getIntegratedLCache() { + return $this->integrated; + } + } diff --git a/src/BackendInvalidator.php b/src/BackendInvalidator.php index 2788ff0..dd0794b 100644 --- a/src/BackendInvalidator.php +++ b/src/BackendInvalidator.php @@ -17,99 +17,15 @@ class BackendInvalidator implements CacheTagsInvalidatorInterface { protected $integrated; - /** - * The database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $connection; - - /** - * The cache tags checksum provider. - * - * @var \Drupal\Core\Cache\CacheTagsChecksumInterface - */ - protected $checksumProvider; - - - protected function get_pdo_handle() { - - - $db_connection_info = Database::getConnectionInfoAsUrl(); - $db_info = Database::getConnection()->getConnectionOptions(); - - - - - // @TODO: Use Drupal's connection arguments or actually pull Drupal's PDO handle. - $dsn = 'mysql:host='. $db_info['host']. ';port='. $db_info['port'] .';dbname='. $db_info['database']; - $options = array(\PDO::ATTR_TIMEOUT => 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); - $dbh = new \PDO($dsn, $db_info['username'], $db_info['password'], $options); - $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $dbh; + public function __construct(\LCache\Integrated $integrated) { + $this->integrated = $integrated; } - /** - * Constructs the BackendFactory object. - */ - public function __construct(Connection $connection) { - - - $this->connection = $connection; - $this->checksumProvider = $checksum_provider; - - // Use the Null L1 cache for the CLI. - $l1 = new \LCache\NullL1(); - if (php_sapi_name() !== 'cli') { - $l1 = new \LCache\APCuL1(); - } - $l2 = new \LCache\DatabaseL2($this->get_pdo_handle()); - $this->integrated = new \LCache\Integrated($l1, $l2); - $this->integrated->synchronize(); - } - - - - /** * {@inheritdoc} */ public function invalidateTags(array $tags) { - - - - $txt .= "tags \n"; - $txt .= print_r($tags, 1); - - $myfile = file_put_contents('/tmp/lcache_invalidate.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX); - - foreach ($tags as $tag) { - - - - - - - - - -// if ($this->bin === 'cache_dynamic_page_cache') { - - - // } - - - - - - - - - - - - $this->integrated->deleteTag($tag); } } From d085f7bfd0c20de715ba57aac3c0eae8c3f83886 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 09:35:30 -0500 Subject: [PATCH 27/82] Back to 255 column size --- lcache.install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lcache.install b/lcache.install index b9b5bf2..97a3f36 100644 --- a/lcache.install +++ b/lcache.install @@ -30,7 +30,7 @@ function lcache_schema() { 'address' => array( 'description' => 'Cache entry address (bin and key).', 'type' => 'varchar_ascii', - 'length' => 2056, + 'length' => 255, 'not null' => FALSE, 'default' => NULL, ), @@ -91,7 +91,6 @@ function lcache_schema() { return $schema; } - /** * Implements hook_install(). */ @@ -104,7 +103,6 @@ function lcache_install() { '); } - /** * Implements hook_uninstall(). */ @@ -114,4 +112,3 @@ function lcache_uninstall() { DROP FOREIGN KEY IF EXISTS {lcache_tags_event_id} '); } - From cd9e6228da5b071b5126d8b9dc37ec8549be328e Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 09:40:59 -0500 Subject: [PATCH 28/82] Whitespace --- src/Backend.php | 1 - src/BackendInvalidator.php | 6 +----- tests/circle-scripts/core-vs-lcache.sh | 8 +------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Backend.php b/src/Backend.php index d7fbeac..6bc9e34 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -7,7 +7,6 @@ namespace Drupal\lcache; -use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; /** diff --git a/src/BackendInvalidator.php b/src/BackendInvalidator.php index dd0794b..2068a74 100644 --- a/src/BackendInvalidator.php +++ b/src/BackendInvalidator.php @@ -2,15 +2,11 @@ /** * @file - * Contains \Drupal\lcache\BackendFactory. + * Contains \Drupal\lcache\BackendInvalidator. */ namespace Drupal\lcache; -use Drupal\Core\Database\Database; -use Drupal\Core\Database\Connection; -use Drupal\Core\Cache\CacheTagsChecksumInterface; - use Drupal\Core\Cache\CacheTagsInvalidatorInterface; class BackendInvalidator implements CacheTagsInvalidatorInterface { diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 84a49a7..9ee6660 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -2,17 +2,13 @@ set -ex - # Create a drush alias file so that Behat tests can be executed against Pantheon. terminus sites aliases # Drush Behat driver fails without this option. echo "\$options['strict'] = 0;" >> ~/.drush/pantheon.aliases.drushrc.php - export BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "http://'$TERMINUS_ENV'-'$TERMINUS_SITE'.pantheonsite.io/"}, "Drupal\\DrupalExtension" : {"drush" : { "alias": "@pantheon.'$TERMINUS_SITE'.'$TERMINUS_ENV'" }}}}' - terminus site set-connection-mode --mode=git - cd ${TERMINUS_SITE} git checkout master git branch -D $TERMINUS_ENV @@ -34,8 +30,7 @@ terminus site clear-cache ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ sleep 15 - - +# Set up LCache repo #composer config repositories.drupal composer https://packages.drupal.org/8 composer config repositories.d8lcache vcs git@github.com:lcache/drupal-8.git composer require drupal/lcache:dev-master#$CIRCLE_SHA1 @@ -60,5 +55,4 @@ git push origin $TERMINUS_ENV ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ - terminus site clear-cache From 037dfc328329f1bfa636a58201241d68aef75fd1 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 10:01:15 -0500 Subject: [PATCH 29/82] Cleaning up behat file --- tests/behat/behat-pantheon.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/behat/behat-pantheon.yml b/tests/behat/behat-pantheon.yml index e5d9280..1bc75cc 100644 --- a/tests/behat/behat-pantheon.yml +++ b/tests/behat/behat-pantheon.yml @@ -4,24 +4,18 @@ default: suites: default: - paths: - - %paths.base%/features - - %paths.base%/common-features contexts: - #- FeatureContext - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\DrushContext - Drupal\DrupalExtension\Context\MinkContext extensions: Behat\MinkExtension: goutte: ~ - selenium2: ~ - files_path: './data-files' # Supplied by env variable. -# base_url: http://dev-persch-d8-solr.pantheonsite.io/ +# base_url: http://dev-d8lcache.pantheonsite.io/ Drupal\DrupalExtension: blackbox: ~ api_driver: 'drush' drush: # Supplied by env variable. -# alias: '@pantheon.persch-d8-solr.dev' +# alias: '@pantheon.d8lcache.dev' From b10b2dc227032d4bb4606f386b418c73ac0040a3 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 10:22:58 -0500 Subject: [PATCH 30/82] Performance comparison --- composer.json | 3 + tests/behat/behat-pantheon.yml | 1 + tests/behat/bootstrap/PerformanceHelpers.php | 135 ++++++++++++++++++ .../create-node-view-all-nodes.feature | 20 +++ tests/circle-scripts/core-vs-lcache.sh | 48 ++++++- 5 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 tests/behat/bootstrap/PerformanceHelpers.php create mode 100644 tests/behat/features/create-node-view-all-nodes.feature diff --git a/composer.json b/composer.json index dbb5f15..e8519e4 100644 --- a/composer.json +++ b/composer.json @@ -18,5 +18,8 @@ "drush-ops/behat-drush-endpoint": "*", "drupal/drupal-extension": "dev-master", "drupal/drupal-driver": "dev-master" + }, + "autoload": { + "psr-4": { "Drupal\\LCache\\Behat\\": "tests/behat/bootstrap/" } } } diff --git a/tests/behat/behat-pantheon.yml b/tests/behat/behat-pantheon.yml index 1bc75cc..639d06f 100644 --- a/tests/behat/behat-pantheon.yml +++ b/tests/behat/behat-pantheon.yml @@ -8,6 +8,7 @@ default: - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\DrushContext - Drupal\DrupalExtension\Context\MinkContext + - Drupal\LCache\Behat\PerformanceHelpers extensions: Behat\MinkExtension: goutte: ~ diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php new file mode 100644 index 0000000..6f96bbd --- /dev/null +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -0,0 +1,135 @@ +getEnvironment(); + $this->minkContext = $environment->getContext('Drupal\DrupalExtension\Context\MinkContext'); + } + + /** + * Fills in form field with specified id|name|label|value + * Example: When I fill in "admin_password2" with a random string "12" characters long + * + * @When I fill in :arg1 with a random string :arg2 characters long + */ + public function fillFieldWithRandomString($field, $length) + { + $this->minkContext->fillField($field, $this->rand_string( $length )); + } + + protected function rand_string( $length ) { + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + $str = ''; + $size = strlen( $chars ); + for( $i = 0; $i < $length; $i++ ) { + $str .= $chars[ rand( 0, $size - 1 ) ]; + } + + return $str; + } + + + /** + * @When I open the links to all homepage posts + */ + public function iOpenTheLinksToAllHomepagePosts() + { + + $this->minkContext->visit("/"); + + + $next_page_exists = TRUE; + $next_page_url =''; + + while($next_page_exists) { + + $page = $this->minkContext->getSession()->getPage(); + $next_page_link = $page->find('css', '.pager__item--next a'); + + + if ($next_page_link) { + $next_page_url = $next_page_link->getAttribute('href'); + } + else { + $next_page_exists = FALSE; + } + + $this->openAllPostLinksOnASinglePage($page); + + if (!empty($next_page_link)) { + $this->minkContext->visit($next_page_url); + } + } + echo "last page visited was $next_page_url"; + } + + + protected function openAllPostLinksOnASinglePage($page) { + + + + $post_urls = $this->getAllPostURLs($page); + + foreach ($post_urls as $post_url) { + + $this->minkContext->visit($post_url); + +// echo "\n"; +// echo $this->minkContext->getSession()->getPage()->find('css', 'h1.entry-title')->getHtml(); +// echo "\n"; +// $this->minkContext->printCurrentUrl(); +// echo "\n"; + } + + } + + + + protected function getAllPostURLs($page) { + + $post_links = $page->findAll('css', 'article header h2 a'); + + $post_urls = []; + foreach ($post_links as $post_link) { + $post_urls[] =$post_link->getAttribute('href'); + } + + print_r($post_urls[0]); + + return $post_urls; + } + + + + /** + * @Given I log in as an admin + */ + public function ILogInAsAnAdmin() + { + $this->minkContext->visit('user'); + $this->minkContext->fillField('name', getenv('DRUPAL_ADMIN_USERNAME')); + $this->minkContext->fillField('pass', getenv('DRUPAL_ADMIN_PASSWORD')); + $this->minkContext->pressButton('Log in'); + //$this->minkContext->printCurrentUrl(); + $this->minkContext->visit('admin'); + //$this->minkContext->printCurrentUrl(); + + } +} diff --git a/tests/behat/features/create-node-view-all-nodes.feature b/tests/behat/features/create-node-view-all-nodes.feature new file mode 100644 index 0000000..b91fa9d --- /dev/null +++ b/tests/behat/features/create-node-view-all-nodes.feature @@ -0,0 +1,20 @@ +Feature: Create node, view all nodes + + + + Background: + Given I log in as an admin + + @api + Scenario: Create node, view all nodes + + +When I visit "node/add/article" +And I fill in "title[0][value]" with "Test article title" +And I fill in "title[0][value]" with a random string "12" characters long +And I press the "Save and publish" button +When I open the links to all homepage posts + + + + diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 9ee6660..09eb263 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -27,7 +27,36 @@ sleep 30 } &> /dev/null terminus site clear-cache -./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ + + +# Make a custom admin user because the normal Drush/Behat way of creating users +# 1) is slow and 2) would require rerunning with each Behat run and 3) +# would result nodes getting deleted at the end of each run. +{ + terminus drush "user-create $DRUPAL_ADMIN_USERNAME" + terminus drush "user-add-role administrator $DRUPAL_ADMIN_USERNAME" + terminus drush "upwd $DRUPAL_ADMIN_USERNAME --password=$DRUPAL_ADMIN_PASSWORD" +} &> /dev/null + + +for i in $(seq 2); do + echo "Peformance test pass $i with Core" + ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature +done + + + + + + + + + + + + + + sleep 15 # Set up LCache repo @@ -53,6 +82,21 @@ git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV -./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/ + +# Make a custom admin user because the normal Drush/Behat way of creating users +# 1) is slow and 2) would require rerunning with each Behat run and 3) +# would result nodes getting deleted at the end of each run. +{ + terminus drush "user-create $DRUPAL_ADMIN_USERNAME" + terminus drush "user-add-role administrator $DRUPAL_ADMIN_USERNAME" + terminus drush "upwd $DRUPAL_ADMIN_USERNAME --password=$DRUPAL_ADMIN_PASSWORD" +} &> /dev/null + + +for i in $(seq 2); do + echo "Peformance test pass $i with Core" + ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature +done + terminus site clear-cache From 39b7d24180a4b04e33ecece76fa712a6d6357898 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 13:00:56 -0500 Subject: [PATCH 31/82] 35 runs with more debugging --- tests/behat/bootstrap/PerformanceHelpers.php | 14 ++++++++++---- tests/circle-scripts/core-vs-lcache.sh | 16 +++------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php index 6f96bbd..49973cb 100644 --- a/tests/behat/bootstrap/PerformanceHelpers.php +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -64,6 +64,11 @@ public function iOpenTheLinksToAllHomepagePosts() $next_page_link = $page->find('css', '.pager__item--next a'); + print_r("\n\n"); + print_r($next_page_url); + print_r("\n\n"); + + if ($next_page_link) { $next_page_url = $next_page_link->getAttribute('href'); } @@ -93,9 +98,9 @@ protected function openAllPostLinksOnASinglePage($page) { // echo "\n"; // echo $this->minkContext->getSession()->getPage()->find('css', 'h1.entry-title')->getHtml(); -// echo "\n"; -// $this->minkContext->printCurrentUrl(); -// echo "\n"; + echo "\n"; + $this->minkContext->printCurrentUrl(); + echo "\n"; } } @@ -111,8 +116,9 @@ protected function getAllPostURLs($page) { $post_urls[] =$post_link->getAttribute('href'); } + print_r("\n\n"); print_r($post_urls[0]); - + print_r("\n\n"); return $post_urls; } diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 09eb263..a27b080 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 2); do +for i in $(seq 35); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done @@ -47,16 +47,6 @@ done - - - - - - - - - - sleep 15 # Set up LCache repo @@ -93,8 +83,8 @@ git push origin $TERMINUS_ENV } &> /dev/null -for i in $(seq 2); do - echo "Peformance test pass $i with Core" +for i in $(seq 35); do + echo "Peformance test pass $i with LCache" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 12455561ce92c37d0184ec09562ab40e02d86efe Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 13 Sep 2016 13:12:58 -0500 Subject: [PATCH 32/82] set username and pass --- circle.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/circle.yml b/circle.yml index d1b7f05..31a5830 100644 --- a/circle.yml +++ b/circle.yml @@ -6,11 +6,18 @@ machine: environment: TERMINUS_ENV: ci-$CIRCLE_BUILD_NUM TERMINUS_SITE: d8lcache + DRUPAL_ADMIN_USERNAME: pantheon + # A random password is set in the dependencies:pre stage as a text file. + # This line reads the same file repeatedly. If the openssl call were used + # in this step, it would result in a different password being used in each + # line of other steps. Each CircleCI command runs in a separate shell. + DRUPAL_ADMIN_PASSWORD: $(cat ~/DRUPAL_ADMIN_PASSWORD) dependencies: cache_directories: - ~/.composer/cache pre: + - echo $(openssl rand -hex 8) > ~/DRUPAL_ADMIN_PASSWORD # Set the PHP timezone so that Behat script does not fail. # Using > instead of >> will overwrite the file and disable xdebug. # xdebug makes composer slower. From de4797e7cc64cb5d9caacab626a6a72771d9b5dd Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Tue, 20 Sep 2016 15:52:39 -0500 Subject: [PATCH 33/82] bumping lcache version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e8519e4..074f2a2 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "lcache/lcache": "v0.2.*" + "lcache/lcache": "v0.3.*" }, "require-dev": { "phpunit/phpunit": "4.*", From bc504652235a5ef35aaa0712e079a5304d87be33 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 14:55:20 -0500 Subject: [PATCH 34/82] set terminus number --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 31a5830..2fd4025 100644 --- a/circle.yml +++ b/circle.yml @@ -26,7 +26,7 @@ dependencies: - git config --global user.name "Circle CI" override: - composer global require "hirak/prestissimo:^0.3" - - composer global require pantheon-systems/terminus + - composer global require pantheon-systems/terminus "<0.13.0" - composer global require drush/drush:8.* - composer install post: From ef4c8d4ee564ea472d0c299a74ae2a1d7cb94ed6 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 14:56:00 -0500 Subject: [PATCH 35/82] table fixes --- lcache.install | 2 +- src/BackendFactory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lcache.install b/lcache.install index 97a3f36..d9df55f 100644 --- a/lcache.install +++ b/lcache.install @@ -23,7 +23,7 @@ function lcache_schema() { 'pool' => array( 'description' => 'PHP process pool that wrote the change.', 'type' => 'varchar', - 'length' => 255, + 'length' => 512, 'not null' => TRUE, 'default' => '', ), diff --git a/src/BackendFactory.php b/src/BackendFactory.php index a35b1d7..a38cca3 100644 --- a/src/BackendFactory.php +++ b/src/BackendFactory.php @@ -16,7 +16,7 @@ class BackendFactory { protected function get_pdo_handle() { $db_info = $this->connection->getConnectionOptions(); $dsn = 'mysql:host='. $db_info['host']. ';port='. $db_info['port'] .';dbname='. $db_info['database']; - $options = array(\PDO::ATTR_TIMEOUT => 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); + $options = array(\PDO::ATTR_TIMEOUT => 2, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES,STRICT_ALL_TABLES"'); $dbh = new \PDO($dsn, $db_info['username'], $db_info['password'], $options); $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $dbh; From c3911a6f0b266facfa44fd7508eab1252b5b61ed Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:05:35 -0500 Subject: [PATCH 36/82] updating debugging output --- tests/behat/bootstrap/PerformanceHelpers.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php index 49973cb..6a6c4c2 100644 --- a/tests/behat/bootstrap/PerformanceHelpers.php +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -62,12 +62,9 @@ public function iOpenTheLinksToAllHomepagePosts() $page = $this->minkContext->getSession()->getPage(); $next_page_link = $page->find('css', '.pager__item--next a'); + //echo $this->minkContext->getSession()->getPage()->find('css', '.pager__items')->getHtml(); - print_r("\n\n"); - print_r($next_page_url); - print_r("\n\n"); - if ($next_page_link) { $next_page_url = $next_page_link->getAttribute('href'); @@ -76,10 +73,16 @@ public function iOpenTheLinksToAllHomepagePosts() $next_page_exists = FALSE; } - $this->openAllPostLinksOnASinglePage($page); + //$this->openAllPostLinksOnASinglePage($page); if (!empty($next_page_link)) { $this->minkContext->visit($next_page_url); + + print_r("\n\n"); + print_r($next_page_url); + print_r("\n\n"); + + //print_r($this->minkContext->getSession()->getResponseHeaders()); } } echo "last page visited was $next_page_url"; @@ -96,11 +99,12 @@ protected function openAllPostLinksOnASinglePage($page) { $this->minkContext->visit($post_url); -// echo "\n"; -// echo $this->minkContext->getSession()->getPage()->find('css', 'h1.entry-title')->getHtml(); + echo "\n"; + echo $this->minkContext->getSession()->getPage()->find('css', 'h1.page-title')->getHtml(); echo "\n"; $this->minkContext->printCurrentUrl(); echo "\n"; + //print_r($this->minkContext->getSession()->getResponseHeaders()); } } @@ -138,4 +142,5 @@ public function ILogInAsAnAdmin() //$this->minkContext->printCurrentUrl(); } + } From 0220364234ef00f8cf69610902e304f03c6eb7b0 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:08:17 -0500 Subject: [PATCH 37/82] 100 test loops --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index a27b080..e6803c5 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 35); do +for i in $(seq 100); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done @@ -83,7 +83,7 @@ git push origin $TERMINUS_ENV } &> /dev/null -for i in $(seq 35); do +for i in $(seq 100); do echo "Peformance test pass $i with LCache" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 447ed27ccff70ae1b3fbae1f4121a396f127893e Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:17:01 -0500 Subject: [PATCH 38/82] 2056 address length --- lcache.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lcache.install b/lcache.install index d9df55f..43b1e64 100644 --- a/lcache.install +++ b/lcache.install @@ -23,7 +23,7 @@ function lcache_schema() { 'pool' => array( 'description' => 'PHP process pool that wrote the change.', 'type' => 'varchar', - 'length' => 512, + 'length' => 2056, 'not null' => TRUE, 'default' => '', ), From c48189a8498b03cae9ee28a4a195055d6425f6fb Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:17:37 -0500 Subject: [PATCH 39/82] fewer test runs --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index e6803c5..2758f04 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 100); do +for i in $(seq 2); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done @@ -83,7 +83,7 @@ git push origin $TERMINUS_ENV } &> /dev/null -for i in $(seq 100); do +for i in $(seq 10); do echo "Peformance test pass $i with LCache" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 9cc75c16f875907ac07c9156df2e2d66f634f3f6 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:21:06 -0500 Subject: [PATCH 40/82] Update lcache.install --- lcache.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lcache.install b/lcache.install index 43b1e64..00f57c4 100644 --- a/lcache.install +++ b/lcache.install @@ -23,14 +23,14 @@ function lcache_schema() { 'pool' => array( 'description' => 'PHP process pool that wrote the change.', 'type' => 'varchar', - 'length' => 2056, + 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'address' => array( 'description' => 'Cache entry address (bin and key).', 'type' => 'varchar_ascii', - 'length' => 255, + 'length' => 512, 'not null' => FALSE, 'default' => NULL, ), From 2aef1e7b8a0a010f69faec078d59602c485463b0 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:53:31 -0500 Subject: [PATCH 41/82] Increasing test runs --- tests/circle-scripts/core-vs-lcache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 2758f04..95de99c 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -83,7 +83,7 @@ git push origin $TERMINUS_ENV } &> /dev/null -for i in $(seq 10); do +for i in $(seq 100); do echo "Peformance test pass $i with LCache" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 1b41d811d0d24d3859ff1213fcc02979f5294f24 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 15:54:22 -0500 Subject: [PATCH 42/82] more repetitions of test runs --- tests/circle-scripts/core-vs-lcache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 95de99c..e6803c5 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 2); do +for i in $(seq 100); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 239a5d25c8a30a82dceb628e83b5b43f8ad19631 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 16:13:33 -0500 Subject: [PATCH 43/82] open all links --- tests/behat/bootstrap/PerformanceHelpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php index 6a6c4c2..10ea482 100644 --- a/tests/behat/bootstrap/PerformanceHelpers.php +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -73,7 +73,7 @@ public function iOpenTheLinksToAllHomepagePosts() $next_page_exists = FALSE; } - //$this->openAllPostLinksOnASinglePage($page); + $this->openAllPostLinksOnASinglePage($page); if (!empty($next_page_link)) { $this->minkContext->visit($next_page_url); From a595cb869604683777c24ea5d82aae3237b6983e Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 18:32:14 -0500 Subject: [PATCH 44/82] LCache instead of ChainedFast --- tests/circle-scripts/core-vs-lcache.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index e6803c5..74df00d 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 100); do +for i in $(seq 2); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done @@ -67,7 +67,13 @@ sleep 60 terminus drush "en lcache -y" terminus site clear-cache -echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php + +# Swap services for the bins otherwise using ChainedFastBackend +echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php + git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV From ffd24536df5dae05b4ab59ae84fb5ab975624511 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 18:35:48 -0500 Subject: [PATCH 45/82] LCache instead of DB for render and dynamic_page_cache --- tests/circle-scripts/core-vs-lcache.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 74df00d..bb84432 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -70,9 +70,17 @@ terminus site clear-cache # echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for the bins otherwise using ChainedFastBackend -echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php + +# Swap services for render, and dynamic page cache. +echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php + + + + git add . git commit -m 'LCache in settings.php' From b9d36a15c1024d2b8879c293b426eb332ef6a970 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 18:56:41 -0500 Subject: [PATCH 46/82] LCache for menu and toolbar --- tests/circle-scripts/core-vs-lcache.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index bb84432..81e6b84 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -77,6 +77,8 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php From 70c8cbedc855f19da1048d340bd60d1cbaf123a8 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 18:57:29 -0500 Subject: [PATCH 47/82] LCache for entity bin --- tests/circle-scripts/core-vs-lcache.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 81e6b84..8a4d95b 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -79,6 +79,7 @@ echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache' echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php From 13f58e086469f3acdb21efb2be850ad77d5c8ce1 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 18:58:11 -0500 Subject: [PATCH 48/82] LCache for data bin --- tests/circle-scripts/core-vs-lcache.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 8a4d95b..e9bfa83 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -80,6 +80,7 @@ echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache' echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php From 12044d85defefccb96e4e50115d149dab4fb9f50 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 19:56:05 -0500 Subject: [PATCH 49/82] Taking data, menu and toolbar out of LCache --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index e9bfa83..6ed3de9 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -77,10 +77,10 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php From f940a3bf79ac7181fe38f12f59426b1a258acafe Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Wed, 21 Sep 2016 19:59:56 -0500 Subject: [PATCH 50/82] 50 runs each --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 6ed3de9..38ab54a 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -39,7 +39,7 @@ terminus site clear-cache } &> /dev/null -for i in $(seq 2); do +for i in $(seq 50); do echo "Peformance test pass $i with Core" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done @@ -101,7 +101,7 @@ git push origin $TERMINUS_ENV } &> /dev/null -for i in $(seq 100); do +for i in $(seq 50); do echo "Peformance test pass $i with LCache" ./../../../vendor/bin/behat --config=../../behat/behat-pantheon.yml ../../behat/features/create-node-view-all-nodes.feature done From 0446e275e769c3d3614239adc8b79684c8749584 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 06:59:19 -0500 Subject: [PATCH 51/82] render bin only --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 38ab54a..c25feb1 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -76,10 +76,10 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php From f9ce7316bde93607a370ee692ace372977645eee Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 07:00:00 -0500 Subject: [PATCH 52/82] dynamic_page_cache bin only --- tests/circle-scripts/core-vs-lcache.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index c25feb1..1b23dd0 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -75,8 +75,8 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php @@ -84,8 +84,6 @@ echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache' - - git add . git commit -m 'LCache in settings.php' git push origin $TERMINUS_ENV From aac41be239590b6b858ca23d5ed24c99a13b8979 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 07:00:27 -0500 Subject: [PATCH 53/82] toolbar only --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 1b23dd0..5a27a39 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -76,8 +76,8 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php -# echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php + echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php From c8775075698ad1cb43c3ad4a3c2b9014156e79a6 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 07:01:01 -0500 Subject: [PATCH 54/82] menu bin only --- tests/circle-scripts/core-vs-lcache.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 5a27a39..5083301 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -77,8 +77,8 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php - echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -# echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php + echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php From 799c4dd064c5390b40c418a39bc68a3cc6f52582 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 07:02:03 -0500 Subject: [PATCH 55/82] entity bin only --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 5083301..51d8735 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -78,14 +78,14 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php - echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache in settings.php' +git commit -m 'LCache for entity bin' git push origin $TERMINUS_ENV From d8b0b5080f29dbb651de3344559ccbfa5972996a Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 07:02:42 -0500 Subject: [PATCH 56/82] data bin only --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 51d8735..a28133a 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -79,13 +79,13 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php -# echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php + echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for entity bin' +git commit -m 'LCache for data bin' git push origin $TERMINUS_ENV From 43024a3255df29fb309c2b90584793a882ab61d4 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 22 Sep 2016 15:38:43 -0500 Subject: [PATCH 57/82] Update BackendUnitTest.php --- src/Tests/BackendUnitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tests/BackendUnitTest.php b/src/Tests/BackendUnitTest.php index 937a00d..e7e4ee6 100644 --- a/src/Tests/BackendUnitTest.php +++ b/src/Tests/BackendUnitTest.php @@ -31,7 +31,7 @@ class BackendUnitTest extends GenericCacheBackendUnitTestBase { * A new LCache Backend object. */ protected function createCacheBackend($bin) { - $factory = new BackendFactory(); + $factory = new BackendFactory($this->container->get('database')); return $factory->get($bin); } } From 845c8f07f6affd13cb1a8e0d40ae3f4e25d0c0f3 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 14:57:59 -0500 Subject: [PATCH 58/82] deleting lcache.cache.inc --- lcache.cache.inc | 160 ----------------------------------------------- 1 file changed, 160 deletions(-) delete mode 100644 lcache.cache.inc diff --git a/lcache.cache.inc b/lcache.cache.inc deleted file mode 100644 index 5fc68e4..0000000 --- a/lcache.cache.inc +++ /dev/null @@ -1,160 +0,0 @@ - 2, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'); - $dbh = new PDO($dsn, $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $options); - $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - return $dbh; -} - -/** - * Defines an L1/L2-based cache implementation. - * - * This cache is based on local APCu data stores and the database. - * Every time a cache item gets updated, we write it to the local cache and the DB. - */ -class LCache implements DrupalCacheInterface { - - /** - * The cache bin. - */ - protected $bin; - - /** - * The integrated L1/L2 cache implementation. - */ - protected $integrated; - - /** - * Constructs an LCache object. - * - * @param $bin - * The cache bin for which the object is created. This will be mostly for the DB cache. - */ - public function __construct($bin=NULL) { - $this->bin = $bin; - - // Use the Null L1 cache for the CLI. - $l1 = new \LCache\NullL1(); - if (php_sapi_name() !== 'cli') { - $l1 = new \LCache\APCuL1(); - } - - $l2 = new \LCache\DatabaseL2(lcache_get_pdo_handle()); - //$l2 = new \LCache\StaticL2(); - - $this->integrated = new \LCache\Integrated($l1, $l2); - //header('LCache-Pool: ' . $this->integrated->getPool()); - } - - protected function getAddress($cid) { - return new \LCache\Address($this->bin, $cid); - } - - /** - * Implements DrupalCacheInterface::get(). - */ - public function get($cid) { - $address = $this->getAddress($cid); - $entry = $this->integrated->getEntry($address); - - if (is_null($entry)) { - return FALSE; - } - - $response = new stdClass(); - $response->cid = $cid; - $response->data = $entry->value; - $response->created = $entry->created; - $response->expire = $entry->expiration; - return $response; - } - - /** - * Implements DrupalCacheInterface::getMultiple(). - */ - public function getMultiple(&$cids) { - if (empty($cids)) return; - $cache = array(); - foreach ($cids as $cid) { - $c = $this->get($cid); - if (!empty($c)) { - $cache[$cid] = $c; - } - } - return $cache; - } - - /** - * Implements DrupalCacheInterface::set(). - */ - public function set($cid, $data, $expire = CACHE_PERMANENT) { - $address = $this->getAddress($cid); - $ttl = NULL; - if ($expire === CACHE_TEMPORARY) { - $ttl = 86400; // @TODO: Use a configurable value. - } - else if ($expire !== CACHE_PERMANENT) { - $ttl = $expire - REQUEST_TIME; - } - $this->integrated->set($address, $data, $ttl); - } - - /** - * Implements DrupalCacheInterface::clear(). - */ - public function clear($cid = NULL, $wildcard = FALSE) { - if (empty($cid)) { - // Flush expired, temporary cache entries now. - $this->integrated->collectGarbage(); - } - else { - if ($wildcard) { - $address = $this->getAddress(); - $this->integrated->delete($address); - } - elseif (is_array($cid)) { - foreach ($cid as $cid_entry) { - $address = $this->getAddress($cid); - $this->integrated->delete($address); - } - } - else { - $address = $this->getAddress($cid); - $this->integrated->delete($address); - } - } - } - - /** - * Implements DrupalCacheInterface::isEmpty(). - */ - public function isEmpty() { - return FALSE; - } - - /** - * Garbage collection for get() and getMultiple(). - * - * @param $bin - * The bin being requested. - */ - protected function garbageCollection() { - } - - public function synchronize() { - $this->integrated->synchronize(); - } -} - -$lcache = new LCache(); -$applied = $lcache->synchronize(); -header('LCache-Changes-Applied: ' . $applied ? $applied : 'NULL'); From 1622216ec383a59d41ddbadaf7a89ac472b86a55 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 14:59:01 -0500 Subject: [PATCH 59/82] cleaning up merge --- lcache.info | 4 ---- src/BackendFactory.php | 1 - 2 files changed, 5 deletions(-) delete mode 100644 lcache.info diff --git a/lcache.info b/lcache.info deleted file mode 100644 index 3a721ef..0000000 --- a/lcache.info +++ /dev/null @@ -1,4 +0,0 @@ -name = "LCache" -description = "Provides a cache using APCu and the database." -package = Performance -core = 7.x diff --git a/src/BackendFactory.php b/src/BackendFactory.php index e0a4482..aa6e778 100644 --- a/src/BackendFactory.php +++ b/src/BackendFactory.php @@ -7,7 +7,6 @@ namespace Drupal\lcache; -<<<<<<< HEAD use Drupal\Core\Database\Connection; /** From 1cdc2e6246d11845b79de91fa37843b6d236cd62 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 14:59:47 -0500 Subject: [PATCH 60/82] cleaning up merge --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1139bd6..3b89c40 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ end_of_line = lf insert_final_newline = true charset = utf-8 -[*.php] +[{*.php,*.module,*.install}] indent_style = space -indent_size = 4 +indent_size = 2 trim_trailing_whitespace = true \ No newline at end of file From acb204f6200a96c2377f1399b1725e3088015c0f Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 15:00:05 -0500 Subject: [PATCH 61/82] cleaning up merge --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 3b89c40..6deeee6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,4 +8,4 @@ charset = utf-8 [{*.php,*.module,*.install}] indent_style = space indent_size = 2 -trim_trailing_whitespace = true \ No newline at end of file +trim_trailing_whitespace = true From 75e35cb0efca7ff8cc67048eb5c58b6f1d338289 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 15:00:57 -0500 Subject: [PATCH 62/82] cleaning up merge --- src/Backend.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Backend.php b/src/Backend.php index fdca8e2..56c7855 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -7,7 +7,6 @@ namespace Drupal\lcache; -use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; /** From 051ed61fdb1223d2efa4850ed005dda2b9cdfb22 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 23 Sep 2016 15:02:01 -0500 Subject: [PATCH 63/82] cleaning up merge --- lcache.module | 2 -- src/Backend.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 lcache.module diff --git a/lcache.module b/lcache.module deleted file mode 100644 index a4abe2d..0000000 --- a/lcache.module +++ /dev/null @@ -1,2 +0,0 @@ -expiration)) { $entry->expiration = CacheBackendInterface::CACHE_PERMANENT; } + $response->expire = $entry->expiration; return $response; } From 03249885e2fe0a57d58eea0d210c7b8b6b9f9460 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 20:51:57 -0700 Subject: [PATCH 64/82] Update circle.yml --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 2fd4025..9723db3 100644 --- a/circle.yml +++ b/circle.yml @@ -2,7 +2,7 @@ machine: php: # https://circleci.com/docs/environment#php - version: 7.0.7 + version: 5.6.14 environment: TERMINUS_ENV: ci-$CIRCLE_BUILD_NUM TERMINUS_SITE: d8lcache @@ -21,7 +21,7 @@ dependencies: # Set the PHP timezone so that Behat script does not fail. # Using > instead of >> will overwrite the file and disable xdebug. # xdebug makes composer slower. - - echo "date.timezone = 'US/Central'" > /opt/circleci/php/7.0.7/etc/conf.d/xdebug.ini + #############- echo "date.timezone = 'US/Central'" > /opt/circleci/php/7.0.7/etc/conf.d/xdebug.ini - git config --global user.email "noreply@pantheon.io" - git config --global user.name "Circle CI" override: From 44720ddc0a06f67f45ad8e2fed2771a19e378e3a Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:01:22 -0700 Subject: [PATCH 65/82] Autoloading --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1be004c..dc04c44 100644 --- a/composer.json +++ b/composer.json @@ -20,5 +20,8 @@ "drush-ops/behat-drush-endpoint": "*", "drupal/drupal-extension": "dev-master", "drupal/drupal-driver": "dev-master" - } + }, + "autoload": { + "psr-4": { "Drupal\\LCache\\Behat\\": "tests/behat/bootstrap/" } + } } From 907ff400310c369dc2c068ef089f1130c44089fa Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:19:59 -0700 Subject: [PATCH 66/82] Bootstrap --- tests/circle-scripts/core-vs-lcache.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index a28133a..58cff28 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -70,7 +70,7 @@ terminus site clear-cache # echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for the bins otherwise using ChainedFastBackend -#echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php @@ -79,13 +79,11 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php - echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php - - +#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# +# echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for data bin' +git commit -m 'LCache for bootstrap bin' git push origin $TERMINUS_ENV From 7b03fb35eee56e5dcdbd75d0e2e3232d07cb815e Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:32:13 -0700 Subject: [PATCH 67/82] 4 node creations --- .../features/create-node-view-all-nodes.feature | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/behat/features/create-node-view-all-nodes.feature b/tests/behat/features/create-node-view-all-nodes.feature index b91fa9d..c413ff6 100644 --- a/tests/behat/features/create-node-view-all-nodes.feature +++ b/tests/behat/features/create-node-view-all-nodes.feature @@ -13,8 +13,20 @@ When I visit "node/add/article" And I fill in "title[0][value]" with "Test article title" And I fill in "title[0][value]" with a random string "12" characters long And I press the "Save and publish" button -When I open the links to all homepage posts +When I visit "node/add/article" +And I fill in "title[0][value]" with "Test article title" +And I fill in "title[0][value]" with a random string "12" characters long +And I press the "Save and publish" button +When I visit "node/add/article" +And I fill in "title[0][value]" with "Test article title" +And I fill in "title[0][value]" with a random string "12" characters long +And I press the "Save and publish" button +When I visit "node/add/article" +And I fill in "title[0][value]" with "Test article title" +And I fill in "title[0][value]" with a random string "12" characters long +And I press the "Save and publish" button +When I open the links to all homepage posts From 2821400f13452e4d9a9aee2233c359dc27bd4ec4 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:33:12 -0700 Subject: [PATCH 68/82] config bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 58cff28..efb5cdc 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -70,8 +70,8 @@ terminus site clear-cache # echo "\$settings['cache']['default'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for the bins otherwise using ChainedFastBackend -echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. @@ -83,7 +83,7 @@ echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sit # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for bootstrap bin' +git commit -m 'LCache for config bin' git push origin $TERMINUS_ENV From 45b36b9cbc4e424473138a2cc9c2fd6e88c7f13a Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:34:25 -0700 Subject: [PATCH 69/82] discovery --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index efb5cdc..4499d3e 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -71,8 +71,8 @@ terminus site clear-cache # Swap services for the bins otherwise using ChainedFastBackend #echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php @@ -83,7 +83,7 @@ echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sit # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for config bin' +git commit -m 'LCache for discovery bin' git push origin $TERMINUS_ENV From d2307bf19829c3ec32e4d33145e644cdb88eeae2 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:35:04 -0700 Subject: [PATCH 70/82] render bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 4499d3e..8372d63 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -72,10 +72,10 @@ terminus site clear-cache # Swap services for the bins otherwise using ChainedFastBackend #echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php @@ -83,7 +83,7 @@ echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sit # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for discovery bin' +git commit -m 'LCache for render bin' git push origin $TERMINUS_ENV From 7d3f69537b2843e3672465976692c42500febfdc Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Thu, 20 Oct 2016 21:35:41 -0700 Subject: [PATCH 71/82] toolbar bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 8372d63..4898578 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -75,15 +75,15 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php -# echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php + echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for render bin' +git commit -m 'LCache for toolbar bin' git push origin $TERMINUS_ENV From 66a565f422ab0160c9cc91612eb8cc58e28f68af Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 08:01:53 -0700 Subject: [PATCH 72/82] menu bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 4898578..b6b6923 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -77,13 +77,13 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php - echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -# echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +# echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for toolbar bin' +git commit -m 'LCache for menu bin' git push origin $TERMINUS_ENV From c262225c1008707fa5e743f49bf02f63e7ce3f87 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 08:02:34 -0700 Subject: [PATCH 73/82] Entity bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index b6b6923..da40d0b 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -78,12 +78,12 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# +#echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for menu bin' +git commit -m 'LCache for entity bin' git push origin $TERMINUS_ENV From 6c81a0d91595cb752da508993fb1ac016ec42717 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 08:36:31 -0700 Subject: [PATCH 74/82] Whitespace --- tests/behat/bootstrap/PerformanceHelpers.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php index 10ea482..ad47d80 100644 --- a/tests/behat/bootstrap/PerformanceHelpers.php +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -2,7 +2,6 @@ namespace Drupal\LCache\Behat; - use Behat\Behat\Context\Context; use Behat\Behat\Context\SnippetAcceptingContext; use Behat\MinkExtension\Context\MinkContext; @@ -54,7 +53,6 @@ public function iOpenTheLinksToAllHomepagePosts() $this->minkContext->visit("/"); - $next_page_exists = TRUE; $next_page_url =''; @@ -63,9 +61,6 @@ public function iOpenTheLinksToAllHomepagePosts() $page = $this->minkContext->getSession()->getPage(); $next_page_link = $page->find('css', '.pager__item--next a'); //echo $this->minkContext->getSession()->getPage()->find('css', '.pager__items')->getHtml(); - - - if ($next_page_link) { $next_page_url = $next_page_link->getAttribute('href'); } @@ -91,14 +86,10 @@ public function iOpenTheLinksToAllHomepagePosts() protected function openAllPostLinksOnASinglePage($page) { - - $post_urls = $this->getAllPostURLs($page); foreach ($post_urls as $post_url) { - $this->minkContext->visit($post_url); - echo "\n"; echo $this->minkContext->getSession()->getPage()->find('css', 'h1.page-title')->getHtml(); echo "\n"; @@ -109,8 +100,6 @@ protected function openAllPostLinksOnASinglePage($page) { } - - protected function getAllPostURLs($page) { $post_links = $page->findAll('css', 'article header h2 a'); @@ -126,8 +115,6 @@ protected function getAllPostURLs($page) { return $post_urls; } - - /** * @Given I log in as an admin */ From 74c8749e4a4e0d9669d1762c1084f3f8f8c2ba96 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 08:55:23 -0700 Subject: [PATCH 75/82] Adding 100 limit --- src/BackendFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BackendFactory.php b/src/BackendFactory.php index bc21d44..d95ffbd 100644 --- a/src/BackendFactory.php +++ b/src/BackendFactory.php @@ -41,7 +41,7 @@ public function __construct(Connection $connection) { $l1 = new \LCache\APCuL1(); } $l2 = new \LCache\DatabaseL2($this->getPdoHandle()); - $this->integrated = new \LCache\Integrated($l1, $l2); + $this->integrated = new \LCache\Integrated($l1, $l2, 100); $this->integrated->synchronize(); } From ddf7d022c2a5bbeac3ddec71b0e4023d4d279089 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 09:44:25 -0700 Subject: [PATCH 76/82] Commenting out logging of urls --- tests/behat/bootstrap/PerformanceHelpers.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/behat/bootstrap/PerformanceHelpers.php b/tests/behat/bootstrap/PerformanceHelpers.php index ad47d80..207d672 100644 --- a/tests/behat/bootstrap/PerformanceHelpers.php +++ b/tests/behat/bootstrap/PerformanceHelpers.php @@ -90,11 +90,11 @@ protected function openAllPostLinksOnASinglePage($page) { foreach ($post_urls as $post_url) { $this->minkContext->visit($post_url); - echo "\n"; - echo $this->minkContext->getSession()->getPage()->find('css', 'h1.page-title')->getHtml(); - echo "\n"; - $this->minkContext->printCurrentUrl(); - echo "\n"; + //echo "\n"; + //echo $this->minkContext->getSession()->getPage()->find('css', 'h1.page-title')->getHtml(); + //echo "\n"; + //$this->minkContext->printCurrentUrl(); + //echo "\n"; //print_r($this->minkContext->getSession()->getResponseHeaders()); } @@ -109,9 +109,9 @@ protected function getAllPostURLs($page) { $post_urls[] =$post_link->getAttribute('href'); } - print_r("\n\n"); - print_r($post_urls[0]); - print_r("\n\n"); + //print_r("\n\n"); + //print_r($post_urls[0]); + //print_r("\n\n"); return $post_urls; } From 98742a5b0df2f49b979a5c710347d01b36f5887f Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 09:45:03 -0700 Subject: [PATCH 77/82] render bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index da40d0b..8ed2566 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -75,15 +75,15 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# +#echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for entity bin' +git commit -m 'LCache for render bin' git push origin $TERMINUS_ENV From 39ceebc153e6fca1a4fd46b1d587845aa0564d36 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 12:00:39 -0700 Subject: [PATCH 78/82] menu bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 8ed2566..b6b6923 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -75,15 +75,15 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for render bin' +git commit -m 'LCache for menu bin' git push origin $TERMINUS_ENV From b41533ad61b470566b7d47b34aaff53479746ab0 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 12:01:19 -0700 Subject: [PATCH 79/82] config --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index b6b6923..0f2ddfa 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -71,19 +71,19 @@ terminus site clear-cache # Swap services for the bins otherwise using ChainedFastBackend #echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for menu bin' +git commit -m 'LCache for config bin' git push origin $TERMINUS_ENV From 5680d3cfae83b61894c9102bd89239c700c185a0 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 12:02:23 -0700 Subject: [PATCH 80/82] render bin --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 0f2ddfa..8ed2566 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -71,11 +71,11 @@ terminus site clear-cache # Swap services for the bins otherwise using ChainedFastBackend #echo "\$settings['cache']['bins']['bootstrap'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php @@ -83,7 +83,7 @@ echo "\$settings['cache']['bins']['config'] = 'cache.backend.lcache';" >> sit # echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for config bin' +git commit -m 'LCache for render bin' git push origin $TERMINUS_ENV From 50928b8bf2c929416540c0c9f791f2235c3dae58 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 12:03:15 -0700 Subject: [PATCH 81/82] dynamic_page_cache bin --- tests/circle-scripts/core-vs-lcache.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index 8ed2566..ab2d74f 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -75,15 +75,15 @@ terminus site clear-cache #echo "\$settings['cache']['bins']['discovery'] = 'cache.backend.lcache';" >> sites/default/settings.php # Swap services for render, and dynamic page cache. -echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# -# echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for render bin' +git commit -m 'LCache for dynamic_page_cache bin' git push origin $TERMINUS_ENV From fe8c44d37ee208233f07b171974b76d77f4fe7e6 Mon Sep 17 00:00:00 2001 From: Steve Persch Date: Fri, 21 Oct 2016 13:45:57 -0700 Subject: [PATCH 82/82] Update core-vs-lcache.sh --- tests/circle-scripts/core-vs-lcache.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/circle-scripts/core-vs-lcache.sh b/tests/circle-scripts/core-vs-lcache.sh index ab2d74f..1ac15ad 100755 --- a/tests/circle-scripts/core-vs-lcache.sh +++ b/tests/circle-scripts/core-vs-lcache.sh @@ -76,14 +76,14 @@ terminus site clear-cache # Swap services for render, and dynamic page cache. #echo "\$settings['cache']['bins']['render'] = 'cache.backend.lcache';" >> sites/default/settings.php -echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php +#echo "\$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.lcache';" >> sites/default/settings.php # echo "\$settings['cache']['bins']['toolbar'] = 'cache.backend.lcache';" >> sites/default/settings.php -#echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php +echo "\$settings['cache']['bins']['menu'] = 'cache.backend.lcache';" >> sites/default/settings.php #echo "\$settings['cache']['bins']['entity'] = 'cache.backend.lcache';" >> sites/default/settings.php# #echo "\$settings['cache']['bins']['data'] = 'cache.backend.lcache';" >> sites/default/settings.php git add . -git commit -m 'LCache for dynamic_page_cache bin' +git commit -m 'LCache for menu bin' git push origin $TERMINUS_ENV