Skip to content

Deadlock while loading another cache in fallback of load() #54

Description

@Vlczech
  • bug report? yes
  • feature request? no
  • version: 2.5.6 (nette/caching)

Description

When trying to load cache by fallback in another fallback of load, script runs to infinity (maybe deadlock?)

Steps To Reproduce

public function runMethodWithCache() {
$cachedValue1 = $this->cache->load('cached_value_1', function(& $dependencies) {
        $dependencies['expire'] = '+1 day';
        $value = $this->runAnotherMethodWithCache();        
        return $value;
      });
}

private function runAnotherMethodWithCache() {
      $usedValue = 'something';
      $this->someValue = $this->cache->load('cached_value_2', function (& $dependencies) use ($usedValue) {
        $dependencies[Cache::ITEMS] = ['cached_value_1'];
        return $usedValue;
      });

     return 'something another';
}

When I comment following lines from second method, script running as expected.

      $this->someValue = $this->cache->load('cached_value_2', function (& $dependencies) use ($usedValue) {
        $dependencies[Cache::ITEMS] = ['cached_value_1'];
        return $usedValue;
      });

[UPDATE 1]: most probably, this is caused by cross dependency of Cache::ITEMS in second method, which is dependent on first one cache.

Idea

If subloading of cache is not possible, it should be inspect to avoid sub-loading of cache.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions