spatie / sheets

Store & retrieve your static content in plain text files

Home Page:https://spatie.be/open-source

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

keep sheet instance references during runtime

Gummibeer opened this issue · comments

If I have larger collections and load this collection multiple times during a request Sheets::collection('large')->all() the memory can quickly explode.
A solution would be to use the already present unique string key for a single sheet in a poor man cache to keep the same sheet object reference for the whole request/runtime.

if (! isset($cache[$collectionName][$sheetName])) {
   $cache[$collectionName][$sheetName] = new Sheet(...);
}

return $cache[$collectionName][$sheetName];

This should be a non breaking change as long as the sheet file isn't changed on runtime. In this case it should be possible to invalidate a cache entry.

The cache logic should be placed in the repository which loads the file content - in this case #45 would provide a solution outside the package. But I would like to provide this as a trait in the package. This way it would be reusable for all custom repositories with a single method call.

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

This issue isn't resolved.