Skip to content

Commit

Permalink
fix: fixing cache enable option (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk authored Jul 30, 2022
1 parent b745d2a commit d3088e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/Cache/PolicyCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public static function keyForPolicyMethods(string $repositoryKey, string $policy

public static function resolve(string $key, callable|Closure $data): mixed
{
if (! static::enabled()) {
return $data();
}

if (Cache::has($key)) {
return Cache::get($key);
}
Expand Down
8 changes: 1 addition & 7 deletions src/Traits/AuthorizableModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ public static function authorizedToUseRepository(Request $request): bool
: false;
};

if (! PolicyCache::enabled()) {
return $resolver();
}

$key = PolicyCache::keyForAllowRestify(static::uriKey());

return PolicyCache::resolve($key, $resolver);
return PolicyCache::resolve(PolicyCache::keyForAllowRestify(static::uriKey()), $resolver);
}

/**
Expand Down

0 comments on commit d3088e3

Please sign in to comment.