grammyjs / files

Handle and download received media files.
MIT License
9 stars 0 forks source link

feat: caching system for InputFile #6

Open KnorpelSenf opened 10 months ago

KnorpelSenf commented 10 months ago

A cache library, Which uses caching system for InputFile. For example:

ctx.replyWithPhoto(...)

When i call it twice i want the second to be fast. Idk if i've elaborated it well

Originally posted by @OfficialCodinary in https://github.com/grammyjs/grammY/issues/110#issuecomment-1881466606

KnorpelSenf commented 10 months ago

How it will work:

  1. Installation via bot.api.config.use(filesCache())
  2. Stores a number of InputFile instances based on the data they contain, ideally with constant-time lookup
  3. Registers a transformer function that adds instances to the cache, and stores the resulting file identifier(s) once the upload has completed
  4. Upon cache hit, the InputFile instance in the payload is replaced by the file identifier received previously if and only if the respective API method permits this according to the specs