Code Monkey home page Code Monkey logo

typo3-redis-lock-strategy's Introduction

github tag Packagist version Scrutinizer Code Quality Travis-CI License


TYPO3 Extension: redis lock strategy

The extension adds a redis lock strategy with priority 100. So the redis lock will be used instead of file base locking, especially useful in cluster with nfs.

Features

  • Redis Lock

Installation

The recommended way to install the extension is by using Composer. In your Composer based TYPO3 project root, just do

composer require tourstream/typo3-redis-lock-strategy 

This extension uses the pecl extension redis.

Usage

$GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
        'host'     => 'localhost',
        'port'     => 6379,       // optional, default 6379
        'database' => 0,          // optional, default 0
        'ttl'      => '60',       // optional, default 60
        'auth'     => 'secret'    // optional, for secured redis db's
    ];

typo3-redis-lock-strategy's People

Contributors

martinez099 avatar engerim avatar pschriner avatar

Stargazers

Konrad Michalik avatar Mario Kehl avatar André Düwel avatar Jules avatar Josef Glatz avatar  avatar

Watchers

James Cloos avatar Josef Glatz avatar Jules avatar

typo3-redis-lock-strategy's Issues

Lock dont get released after script is done

There should be a destructor in RedisLockStrategy.php to release the lock otherwise it takes the full ttl time until lock is released (maybe not in every case, i encounter this issue with redirects).

    /**
     * Destructor:
     * Releases lock automatically when instance is destroyed and release resources
     */
    public function __destruct()
    {
        $this->release();
    }

isAcquired() does not check the local state of the lock

public function isAcquired()

According to the TYPO3 v8 LTS documentation
https://api.typo3.org/typo3cms/8/html/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_locking_1_1_file_lock_strategy.html#a0f229327d7b37102655de41f106152e7
this function should check if this locker has acquired the lock, meaning the process owning this lock is allowed to execute the critical part. But as it is implemented, it checks the global state of the lock in the REDIS datastore which is wrong.

acquire() is neither blocking nor acquires an exclusive lock

public function acquire($mode = self::LOCK_CAPABILITY_EXCLUSIVE)

According to the TYPO3 v8 LTS documentation https://api.typo3.org/typo3cms/8/html/interface_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_locking_1_1_locking_strategy_interface.html#a09d8a107b07d88279198923eb92a8737
this function called without arguments should acquire an exclusive lock. If the lock is acquired by another process, it should block (wait) until the lock is released by that process, acquire the lock and return. In fact, this function as implemented does nothing of that but does return in (nearly) every case the boolean value TRUE, what makes the whole locker unnecessary.

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.