When and how is the $logIndex variable in class LogReader stored? #69
-
I can't find the code when saving the value to know what $logIndex looks like . I really don't know how you got the index of each line of its logs. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @truongbo17 , Check the 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 When opening the file for the second time, the index is loaded from the cache (see the Hope this makes sense! :) P.S. There are some changes coming later to how the index is built up, so please don't make any PRs related to indexing for now. |
Beta Was this translation helpful? Give feedback.
Hey @truongbo17 ,
Check the
LogReader::close()
method - https://github.com/opcodesio/log-viewer/blob/main/src/LogReader.php#L215When 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 …