Coder Social home page Coder Social logo

Using with Dependency fail about cache-db HOT 2 CLOSED

Gerych1984 avatar Gerych1984 commented on June 12, 2024
Using with Dependency fail

from cache-db.

Comments (2)

terabytesoftw avatar terabytesoftw commented on June 12, 2024

Good day. I have next case:

  1. Some external paid API with limited requests per time
  2. The parts of the methods from this API free for use (like version, data-version, balance etc)
  3. I cached paid results from this API using cache-db (to be independent from reboot of production machine). It's ok
  4. Today i start using TagDependency with tag equals $api->dataVersion() and i have fail with $value['data'] is resource instead of string and it cannot be unserialized. But it's still works without dependency

DB - PostgreSql 14 with bytea data type

Please could you write the code that fails to reproduce the problem,

from cache-db.

Gerych1984 avatar Gerych1984 commented on June 12, 2024

Good day. I have next case:

  1. Some external paid API with limited requests per time
  2. The parts of the methods from this API free for use (like version, data-version, balance etc)
  3. I cached paid results from this API using cache-db (to be independent from reboot of production machine). It's ok
  4. Today i start using TagDependency with tag equals $api->dataVersion() and i have fail with $value['data'] is resource instead of string and it cannot be unserialized. But it's still works without dependency

DB - PostgreSql 14 with bytea data type

Please could you write the code that fails to reproduce the problem,

public function __call($name, $arguments)
    {
        if (!is_callable([$this->client, $name])) {
            throw new BadMethodCallException();
        }

        $version = $this->getVersion('factor'); //wiil return string like "8.0 (90780)"  or null if API has some error
        $key = array_merge([__CLASS__, $name], $arguments);

        if ($version) {
            $ttl = null;
            $dependency = new TagDependency($version);
        } else {
            $ttl = 86400;
            $dependency  = null;
        }
        
        return $this->cache->getOrSet($key, function() use ($name, $arguments) {
            return $this->client->{$name}(...$arguments);
        }, $ttl, $dependency);
    }

from cache-db.

Related Issues (6)

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.