karelwintersky/arris.toolkit.nginx

Arris µFramework NGINX Helper

2.0 2021-05-19 22:57 UTC

This package is auto-updated.

Last update: 2022-05-20 01:14:49 UTC


README

composer require karelwintersky/arris.toolkit.nginx 

How To

Init class first (version 2.0+)

use Arris\Toolkit\NginxToolkit;

$app = App::factory();

$app->set('nginx:helper', new NginxCacheHelper($options, $logger) );

Options are hash-array of:

  • isUseCache - использовать ли кэш? - default = false
  • cache_root - путь до кэша nginx - required
  • cache_levels - уровни кэша - default = '1:2'
  • cache_key_format - определение формата ключа - default = 'GET|||HOST|PATH'

Logger can be:

  • null,
  • monolog logger instance
  • AppLogger::scope() call

Use

$app->get('nginx:helper')->clearCache('/articles/1345');
$app->get('nginx:helper')->clearCache('/');
$app->get('nginx:helper')->clearCacheEntire();

clearCache('/') equal to clearCacheEntire()

Methods

/**
 * Init NGINX Cache Helper class
 * Инициализирует NGINX Cache Helper class
 *
 * @param array $options (default [])
 * Options:
 * - isUseCache     -- default(false)               -- использовать ли кэш? -- env(NGINX.CACHE_USE)
 * - cache_root     -- required                     -- путь до кэша nginx   -- env(NGINX.CACHE_PATH)
 * - cache_levels   -- default('1:2')               -- уровни кэша          -- env(NGINX.CACHE_LEVELS)
 * - cache_key_format -- default('GET|||HOST|PATH') -- определение формата ключа -- env(NGINX.CACHE_KEY_FORMAT)
 *
 * @param LoggerInterface $logger - передаем null или AppLogger::scope()
 * 
 * @throws Exception
 */
__constructor($options = [], $logger = null);
/**
 * Clear NGINX Cache record for given URL
 * Очищает nginx-кэш для переданного URL
 *
 * @param string $url
 * @return bool
 * @throws Exception
 */
clearCache(string $url);
/**
 * Clear entire NGINX Cache
 * Полная очистка КЭША NGINX
 *
 * @return bool
 * @throws Exception
 */
clearCacheEntire();

version 1.7

Init class first (v 1.7)

use Arris\Toolkit\NginxToolkit;

NginxToolkit::init($options, $logger)

Options are hash-array of:

  • isUseCache - использовать ли кэш? - default = false
  • cache_root - путь до кэша nginx - required
  • cache_levels - уровни кэша - default = '1:2'
  • cache_key_format - определение формата ключа - default = 'GET|||HOST|PATH'

Logger can be:

  • null,
  • monolog logger instance
  • AppLogger::scope() call

Methods (v 1.7)

/**
 * Init NGINX Toolkit static class
 * Инициализирует NGINX Toolkit static class
 *
 * @param array $options (default [])
 * Options:
 * - isUseCache     -- default(false)               -- использовать ли кэш? -- env(NGINX.CACHE_USE)
 * - cache_root     -- required                     -- путь до кэша nginx   -- env(NGINX.CACHE_PATH)
 * - cache_levels   -- default('1:2')               -- уровни кэша          -- env(NGINX.CACHE_LEVELS)
 * - cache_key_format -- default('GET|||HOST|PATH') -- определение формата ключа -- env(NGINX.CACHE_KEY_FORMAT)
 *
 * @param LoggerInterface $logger - передаем null или AppLogger::scope()
 * 
 * @throws Exception
 */
init($options = [], $logger = null);
/**
 * Clear NGINX Cache record for given URL
 * Очищает nginx-кэш для переданного URL
 *
 * @param string $url
 * @return bool
 * @throws Exception
 */
clear_nginx_cache(string $url);
/**
 * Clear entire NGINX Cache
 * Полная очистка КЭША NGINX
 *
 * @return bool
 * @throws Exception
 */
clear_nginx_cache_entire();

License

MIT License

Copyright (c) 2018 Turing Analytics LLP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.