freearhey / epg-grabber

Node.js CLI tool for grabbing EPG from different websites
47 stars 7 forks source link

Enable cache configuration and provide storage. #20

Closed tohenk closed 9 months ago

tohenk commented 9 months ago

Pass cache configuration to setupCache() and provide default storage used as storage for next requests.

tohenk commented 9 months ago

Without providing cache storage in configuration, it is impossible to cache the response. Every time the request made, so storage cache also created on the fly.

freearhey commented 9 months ago

In fact, the create() function should be called only once when creating an new EPGGrabber() instance and each instance should use its own storage so that they do not conflict with each other.

But I forgot about it when I updated the code in iptv-org/epg and as a result a new EPGGrabber instance is created with each request: https://github.com/iptv-org/epg/blob/83c80cec526d913b5bab5754c524d946ad072bcf/scripts/core/grabber.ts#L51-L52

To fix this in the last update I added the possibility to pass the config through grab() method which will allow to change it at each request while keeping the same storage: https://github.com/freearhey/epg-grabber/commit/f2db2cd8f5bd79c14fdb7ccf380ba5a7a777b70b

I have also updated the iptv-org/epg code (https://github.com/iptv-org/epg/commit/13fc52132d781d95f400563ea5014a682e0315f2), so caching should work fine now.