ankitpokhrel / ankitpokhrel/tus-php
Less Cache writes during Uploads (right now every 8 Kbytes)
- Lingua principale
- PHP
- Stelle
- 1.5k
- Fork
- 220
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**Is your feature request related to a problem? Please describe.**
During a file Upload operation, files are copied using a constant/8 Kbytes chunks.
As seen here: https://github.com/ankitpokhrel/tus-php/blob/a466a9b835f3ea29ec4df7e37a2dc9e00d194304/src/File.php#L331
On every offset/bytes increment the `Cache` is Set using the new Offset value, all this inside a `While` driven by a seek. This is a blocking operation and the While eventually (at the end of the seek or if something goes wrong) will exist and return the offset. Writing to cache on every 8Kbytes seems excessive and could be just done before returning the offset?
**Describe the solution you'd like**
Move the `$this->cache->set($key, ['offset' => $this->offset]);` after the `while` exists.
**Describe alternatives you've considered**
I might be missing some edge case/parallel operation? of why the cache needs to be written very 8 Kbytes? At least, on a DB based cache implementation, this effectively delays the actual File availability (the client is done sending) considerably.
**Additional context**
Any pointers on why this behavior exists would be greatly appreciated. I locally moved the set cache outside of the while and my performance on very large files improved dramatically. Also, thanks a lot for your excellent code.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.