Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep sheet instance references during runtime #46

Closed
Gummibeer opened this issue Nov 14, 2019 · 2 comments · Fixed by #47
Closed

keep sheet instance references during runtime #46

Gummibeer opened this issue Nov 14, 2019 · 2 comments · Fixed by #47

Comments

@Gummibeer
Copy link
Contributor

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.

@spatie-bot
Copy link

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.

@Gummibeer
Copy link
Contributor Author

This issue isn't resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants