Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ecddcf9
Drupal test additions
stevector Sep 22, 2016
c283feb
adding travis
stevector Sep 22, 2016
a5ea2b0
Adding travis phpcs
stevector Sep 22, 2016
3374fdb
Trying to install lcache
stevector Sep 22, 2016
3738cec
comment out before_install
stevector Sep 22, 2016
ff32d74
Trying to get Travis to run
stevector Sep 23, 2016
25e4056
Circle for running core tests
stevector Sep 23, 2016
2d6d6f1
[ci skip] Deleting travis
stevector Sep 23, 2016
ae76c8f
[ci skip] Deleting travis
stevector Sep 23, 2016
efdcdf7
whitespace change
stevector Sep 23, 2016
cf35cf2
php 5.6.14
stevector Sep 23, 2016
ef0ec57
Getting tests to run
stevector Sep 23, 2016
84da9de
Update circle.yml
stevector Sep 23, 2016
5210d23
gitignore
stevector Sep 23, 2016
5bdcfae
Ignoring fail from https://circleci.com/gh/lcache/drupal-8/70
stevector Sep 23, 2016
fedd626
[ci skip] adding coder, codesniffer
stevector Sep 23, 2016
d2d7f3e
Adding code sniffing tests
stevector Sep 23, 2016
dd7b659
Adding ignore on coding standards in src/Tests/BackendUnitTest.php
stevector Sep 23, 2016
bef8878
PHPCS call correction
stevector Sep 23, 2016
97b23d1
PHPCS fixes
stevector Sep 23, 2016
9450593
PHPCS in BackendFactory
stevector Sep 23, 2016
0780389
PHPCS in BackendFactory
stevector Sep 23, 2016
ffd9ab3
composer.lock in gitignore
stevector Sep 23, 2016
0bcee86
Merge branch 'basic-tests-with-circle' of github.com:lcache/drupal-8 …
stevector Sep 23, 2016
3c2210a
PHPCS in BackendFactory
stevector Sep 23, 2016
338b389
PHPCS in BackendFactory
stevector Sep 23, 2016
ff132af
PHPCS in Backend
stevector Sep 23, 2016
ce88bc3
Removing unneeded .module file
stevector Sep 23, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
/drush/
/vendor/
70 changes: 70 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# https://circleci.com/docs/configuration#machine
machine:
php:
# https://circleci.com/docs/environment#php
version: 5.6.14
environment:
# DB config. Using default CircleCI's database.
DB_NAME: "circle_test"
DB_USERNAME: "ubuntu"
DB_PASSWORD: ""
DOCROOT: "$HOME/drupalcore"
SERVER: server.local
WEB_USER: $(whoami)
WEB_GROUP: www-data
hosts:
server.local: 127.0.0.1

dependencies:
cache_directories:
- ~/.composer/cache
pre:
- composer global require "hirak/prestissimo:^0.3"
- composer global require drush/drush:8.*
# @todo, composer is probably a bad/slow way to install core here.
# Use something like drush's
- git clone --branch 8.1.x https://git.drupal.org/project/drupal.git $DOCROOT
- cd $DOCROOT && composer install
# Add apache config.
# Modify user to make sure that there will be no permission issues.
- sudo usermod -a -G $WEB_GROUP $WEB_USER
# Add apache config.
- |
echo "<VirtualHost *:80>
UseCanonicalName Off
DocumentRoot %DOCROOT%
ServerName %SERVER%
<Directory %DOCROOT%>
Options FollowSymLinks
AllowOverride All
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule %DOCROOT%/(.*)$ index.php/?q=$1 [L,QSA]
Order allow,deny
Allow from all
</Directory>
</VirtualHost>" > apache-vhost.conf
- cp apache-vhost.conf /etc/apache2/sites-available/default
- sudo sed -e "s?%DOCROOT%?$DOCROOT?g" --in-place /etc/apache2/sites-available/default
- sudo sed -e "s?%SERVER%?$SERVER?g" --in-place /etc/apache2/sites-available/default
- sudo a2enmod rewrite
- sudo service apache2 restart
test:
pre:
# Copy the settings.local into place
# Disable sendmail binary to suppress any mailouts.
- echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/circle.ini
- drush --yes --root=$DOCROOT site-install --db-url=mysql://$DB_USERNAME:[email protected]/$DB_NAME
- curl $SERVER
- cd $DOCROOT && drush en simpletest -y
- cd $DOCROOT && composer config repositories.d8lcache vcs [email protected]:lcache/drupal-8.git
- cd $DOCROOT && composer require "drupal/lcache:dev-master#$CIRCLE_SHA1"
- cd $DOCROOT && drush en lcache -y

override:
- ./vendor/bin/phpcs --report=full --extensions=php,module,inc,theme,info --standard=vendor/drupal/coder/coder_sniffer/Drupal/ --ignore=vendor .
- cd $DOCROOT && /home/ubuntu/.phpenv/shims/php core/scripts/run-tests.sh --url $SERVER --module lcache --php /home/ubuntu/.phpenv/shims/php --verbose --color


4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lcache/lcache": "v0.3.*"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"phpunit/dbunit": "*"
"drupal/coder": "^8.2.0-beta1",
"squizlabs/php_codesniffer": "2.0.*@dev"
}
}
2 changes: 0 additions & 2 deletions lcache.module

This file was deleted.

2 changes: 1 addition & 1 deletion lcache.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
arguments: ['@database']
lcache.integrated:
class: LCache\Integrated
factory: cache.backend.lcache:getIntegratedLCache
factory: cache.backend.lcache:getIntegratedLcache
cache_tags.invalidator.lcache:
class: Drupal\lcache\BackendInvalidator
arguments: ['@lcache.integrated']
Expand Down
32 changes: 21 additions & 11 deletions src/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Backend implements CacheBackendInterface {

/**
* Constructs a Backend object.
*
* @param string $bin
* The bin name.
*/
Expand All @@ -38,6 +39,12 @@ public function __construct($bin, \LCache\Integrated $integrated) {
$this->integrated = $integrated;
}

/**
* Return an Address for a given cid.
*
* @param string $cid
* The Cache ID.
*/
protected function getAddress($cid) {
return new \LCache\Address($this->bin, $cid);
}
Expand All @@ -55,8 +62,17 @@ public function get($cid, $allow_invalid = FALSE) {

$response = new \stdClass();
$response->cid = $cid;
$response->valid = TRUE;
$response->data = $entry->value;
$response->created = $entry->created;

// LCache the library uses NULL for permanent
// but that may confuse parts of Drupal.
// @todo, investigate if there is a better answer than this munging.
if (is_null($entry->expiration)) {
$entry->expiration = CacheBackendInterface::CACHE_PERMANENT;
}

$response->expire = $entry->expiration;
return $response;
}
Expand All @@ -65,14 +81,17 @@ public function get($cid, $allow_invalid = FALSE) {
* {@inheritdoc}
*/
public function getMultiple(&$cids, $allow_invalid = FALSE) {
if (empty($cids)) return;
if (empty($cids)) {
return;
}
$cache = array();
foreach ($cids as $cid) {
$c = $this->get($cid);
if (!empty($c)) {
$cache[$cid] = $c;
}
}
$cids = array_diff($cids, array_keys($cache));
return $cache;
}

Expand Down Expand Up @@ -164,15 +183,6 @@ public function invalidateAll() {
$this->delete(NULL);
}

/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags) {
foreach ($tags as $tag) {
$this->integrated->deleteTag($tag);
}
}

/**
* {@inheritdoc}
*/
Expand All @@ -188,7 +198,7 @@ public function garbageCollection() {
}

/**
* (@inheritdoc)
* {@inheritdoc}
*/
public function isEmpty() {
return FALSE;
Expand Down
17 changes: 11 additions & 6 deletions src/BackendFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@

use Drupal\Core\Database\Connection;

/**
* A Factory for an LCache backend.
*/
class BackendFactory {

protected $integrated;

protected function get_pdo_handle() {
/**
* Constructs the the databse connection for L2.
*/
protected function getPdoHandle() {
$db_info = $this->connection->getConnectionOptions();
$dsn = 'mysql:host='. $db_info['host']. ';port='. $db_info['port'] .';dbname='. $db_info['database'];
$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,STRICT_ALL_TABLES"');
$dbh = new \PDO($dsn, $db_info['username'], $db_info['password'], $options);
$dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
Expand All @@ -34,15 +40,15 @@ public function __construct(Connection $connection) {
if (php_sapi_name() !== 'cli') {
$l1 = new \LCache\APCuL1();
}
$l2 = new \LCache\DatabaseL2($this->get_pdo_handle());
$l2 = new \LCache\DatabaseL2($this->getPdoHandle());
$this->integrated = new \LCache\Integrated($l1, $l2);
$this->integrated->synchronize();
}

/**
* Gets an LCache Backend for the specified cache bin.
*
* @param $bin
* @param string $bin
* The cache bin for which the object is created.
*
* @return \Drupal\lcache\Backend
Expand All @@ -58,8 +64,7 @@ public function get($bin) {
* @return \LCache\Integrated
* The integrated cache backend.
*/
public function getIntegratedLCache() {
public function getIntegratedLcache() {
return $this->integrated;
}

}
12 changes: 10 additions & 2 deletions src/BackendInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@

use Drupal\Core\Cache\CacheTagsInvalidatorInterface;

/**
* Invalidates LCache tags.
*/
class BackendInvalidator implements CacheTagsInvalidatorInterface {

protected $integrated;

/**
* Constructs an invalidator object.
*
* @param \LCache\Integrated $integrated
* The integrated Cache object were invalidations will be run.
*/
public function __construct(\LCache\Integrated $integrated) {
$this->integrated = $integrated;
}
Expand All @@ -22,8 +31,7 @@ public function __construct(\LCache\Integrated $integrated) {
*/
public function invalidateTags(array $tags) {
foreach ($tags as $tag) {
$this->integrated->deleteTag($tag);
$this->integrated->deleteTag($tag);
}
}

}
Loading