GithubHelp home page GithubHelp logo

psr16cache-adapter's Introduction

Latest Stable Version Latest Unstable Version Total Downloads Monthly Downloads License

Scrutinizer Code Quality Build Status Code Coverage

Code Climate Issue Count

PSR-16 Cache Adapter

Instalation

composer require mrcnpdlk/psr16cache-adapter

Basic usage

$oInstanceCacheFile = new \phpFastCache\Helper\Psr16Adapter(
    'files',
    [
        "host"                => null, // default localhost
        "port"                => null, // default 6379
        'defaultTtl'          => 3600 * 24, // 24h
        'ignoreSymfonyNotice' => true,
    ]);
$oInstanceLogger    = new \Monolog\Logger('name_of_my_logger');
$oInstanceLogger->pushHandler(new \Monolog\Handler\ErrorLogHandler(
        \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM,
        \Psr\Log\LogLevel::DEBUG
    )
);

$oCacheAdapter = new \mrcnpdlk\Psr16Cache\Adapter($oInstanceCacheFile, $oInstanceLogger);
$oCacheAdapter->setHashSalt(['some_hash', __DIR__]);

$res = $oCacheAdapter->useCache(
    function () {
        return '1';
    },
    ['key1', 'key2'],
    10
);

var_dump($res);

Response

[2017-10-16 19:17:41] name_of_my_logger.DEBUG: CACHE [ffe7efd40ef900c95726a859aa28e048]: old, reset [] []
string(1) "1"

[2017-10-16 19:17:44] name_of_my_logger.DEBUG: CACHE [ffe7efd40ef900c95726a859aa28e048]: getting from cache [] []
string(1) "1"

Running the tests

./vendor/bin/phpunit

Authors

  • Marcin Pudełek - Initial work - mrcnpdlk

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

psr16cache-adapter's People

Contributors

mrcnpdlk avatar

Stargazers

Artur Bartczak avatar

Watchers

James Cloos avatar

Forkers

dbojdo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.