Giter VIP home page Giter VIP logo

Comments (4)

marc-mabe avatar marc-mabe commented on August 29, 2024

@remicollet thanks for this great idea!

A few questions:

When control enters apcu_entry() the lock for the cache is acquired exclusively, it is released when control leaves apcu_entry()

  • Does that mean the lock for the exact same entry/key or are there other entries/keys effected, too?
  • "exclusively" means other processes reading and writing the same key are waiting for the callback to finish.
    • Are other writes waiting for the lock to finish and afterwards overwrite the entry? Or are concurrent writes directly blocked (return false)? Does that makes sense?
    • -> This could happen if you have different logic writing the same entry like cache warm-up.

The only APCu function that can be called safely by generator is apcu_entry().

For me it means that the result of the callback will be automatically written to cache so your implementation would not be correct as it doesn't store the result. Or should the generator function take care or writing the valid result into cache? This would be more flexible because of some generator function doesn't throw exceptions or also could generate more than one entries.

Marc

from zend-cache.

remicollet avatar remicollet commented on August 29, 2024

it doesn't store the result.

Fixed

from zend-cache.

remicollet avatar remicollet commented on August 29, 2024

For APCU implementation, see https://github.com/krakjoe/apcu/blob/master/apc_cache.c#L1807

The idea is that the lock is set before the get, so this ensure the callback/store will be execute only once, and then used by other process.

I think this make sense expecially when the cached value require very long computation.

from zend-cache.

weierophinney avatar weierophinney commented on August 29, 2024

This repository has been closed and moved to laminas/laminas-cache; a new issue has been opened at laminas/laminas-cache#11.

from zend-cache.

Related Issues (20)

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.