Skip to content

Commit 789afe6

Browse files
committed
Laravel may return either an object or a collection. If laravel-model-caching uses the same cache key, it will reutrn on of the two. See the comments by @zhenyangze. This is just a simple commit to make a pull request for his recommended fix.
1 parent 6997acb commit 789afe6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/CachedBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function find($id, $columns = ["*"])
6161
}
6262

6363
$idKey = collect($id)->implode('-');
64-
$cacheKey = $this->makeCacheKey($columns, null, "-find_{$idKey}");
64+
$preStr = is_array($id) ? 'find-list' : 'find';
65+
$cacheKey = $this->makeCacheKey($columns, null, "-" . $preStr . "_{$idKey}");
6566

6667
return $this->cachedValue(func_get_args(), $cacheKey);
6768
}

0 commit comments

Comments
 (0)