Skip to content

When and how is the $logIndex variable in class LogReader stored? #69

Answered by arukompas
truongbo17 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @truongbo17 ,

Check the LogReader::close() method - https://github.com/opcodesio/log-viewer/blob/main/src/LogReader.php#L215

When the file is closed (this means we're finished with it and we're cleaning up), it checks whether the index has changed. If so - it writes it into cache. It uses Laravel's Cache facade, so it uses your app's default cache driver (file, redis, etc)

When opening the file for the second time, the index is loaded from the cache (see the LogReader::open() method). If the file hasn't changed, then the index does not change either and upon closing it does not write into cache again.

Hope this makes sense! :)

P.S. There are some changes coming later to how the index …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@truongbo17
Comment options

@arukompas
Comment options

@truongbo17
Comment options

Answer selected by arukompas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants