From 2da5ffa12eb2d2ab9cd95d751f521eb8ab699563 Mon Sep 17 00:00:00 2001 From: Pedro Tanaka Date: Fri, 8 Jan 2021 09:40:07 +0100 Subject: [PATCH] Introducing cached adapters to reduce IO/HTTP overhead while handling files --- composer.json | 3 +- composer.lock | 63 ++++++++++++++++++++++++++++++++-- config/packages/flysystem.yaml | 28 +++++++++++++-- symfony.lock | 3 ++ 4 files changed, 91 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 5f3139f3..2b6d62d9 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,9 @@ "ext-curl": "*", "ext-iconv": "*", "ext-intl": "*", + "ext-json": "*", "ext-pdo_pgsql": "*", "ext-zip": "*", - "ext-json": "*", "bitbucket/client": "^2.1", "buddy-works/buddy-works-php-api": "^1.3", "buddy-works/oauth2-client": "^0.1", @@ -29,6 +29,7 @@ "league/commonmark": "^1.5", "league/flysystem-aws-s3-v3": "^1.0", "league/flysystem-bundle": "^1.5", + "league/flysystem-cached-adapter": "^1.1", "league/oauth2-github": "^2.0", "m4tthumphrey/php-gitlab-api": "^9.17", "munusphp/munus": "^0.2.1", diff --git a/composer.lock b/composer.lock index cb4a8e51..d82ff280 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c5d2b3351842b6a34cdcd52df4c327a5", + "content-hash": "279f4809d6a493f5a2c973b1737e70d1", "packages": [ { "name": "aws/aws-sdk-php", @@ -3992,6 +3992,63 @@ }, "time": "2020-04-04T22:09:59+00:00" }, + { + "name": "league/flysystem-cached-adapter", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-cached-adapter.git", + "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff", + "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff", + "shasum": "", + "mirrors": [ + { + "url": "https://repo.repman.io/dists/%package%/%version%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "league/flysystem": "~1.0", + "psr/cache": "^1.0.0" + }, + "require-dev": { + "mockery/mockery": "~0.9", + "phpspec/phpspec": "^3.4", + "phpunit/phpunit": "^5.7", + "predis/predis": "~1.0", + "tedivm/stash": "~0.12" + }, + "suggest": { + "ext-phpredis": "Pure C implemented extension for PHP" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\Cached\\": "src/" + } + }, + "notification-url": "https://repo.repman.io/downloads", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "frankdejonge", + "email": "info@frenky.net" + } + ], + "description": "An adapter decorator to enable meta-data caching.", + "support": { + "issues": "https://github.com/thephpleague/flysystem-cached-adapter/issues", + "source": "https://github.com/thephpleague/flysystem-cached-adapter/tree/master" + }, + "time": "2020-07-25T15:56:04+00:00" + }, { "name": "league/mime-type-detection", "version": "1.4.0", @@ -17123,9 +17180,9 @@ "ext-curl": "*", "ext-iconv": "*", "ext-intl": "*", + "ext-json": "*", "ext-pdo_pgsql": "*", - "ext-zip": "*", - "ext-json": "*" + "ext-zip": "*" }, "platform-dev": [], "plugin-api-version": "2.0.0" diff --git a/config/packages/flysystem.yaml b/config/packages/flysystem.yaml index 853c240e..01f10ab2 100644 --- a/config/packages/flysystem.yaml +++ b/config/packages/flysystem.yaml @@ -6,11 +6,23 @@ flysystem: options: directory: '%dists_dir%' + storage.local.cached.proxy: + adapter: 'cache' + options: + store: 'cache.app' + source: 'storage.local.proxy' + storage.local.repo: adapter: 'local' options: directory: '%repo_dir%' + storage.local.cached.repo: + adapter: 'cache' + options: + store: 'cache.app' + source: 'storage.local.repo' + storage.s3.proxy: adapter: 'aws' options: @@ -18,6 +30,12 @@ flysystem: bucket: '%env(STORAGE_AWS_BUCKET)%' prefix: '%dists_dir%' + storage.s3.cached.proxy: + adapter: 'cache' + options: + store: 'cache.app' + source: 'storage.s3.proxy' + storage.s3.repo: adapter: 'aws' options: @@ -25,12 +43,18 @@ flysystem: bucket: '%env(STORAGE_AWS_BUCKET)%' prefix: '%repo_dir%' + storage.s3.cached.repo: + adapter: 'cache' + options: + store: 'cache.app' + source: 'storage.s3.repo' + repo.storage: adapter: 'lazy' options: - source: '%env(STORAGE_SOURCE)%.repo' + source: '%env(STORAGE_SOURCE)%.cached.repo' proxy.storage: adapter: 'lazy' options: - source: '%env(STORAGE_SOURCE)%.proxy' + source: '%env(STORAGE_SOURCE)%.cached.proxy' diff --git a/symfony.lock b/symfony.lock index ece94f52..38099a30 100644 --- a/symfony.lock +++ b/symfony.lock @@ -298,6 +298,9 @@ "var/storage/.gitignore" ] }, + "league/flysystem-cached-adapter": { + "version": "1.1.0" + }, "league/flysystem-memory": { "version": "1.0.2" },