ankitpokhrel / ankitpokhrel/tus-php

Less Cache writes during Uploads (right now every 8 Kbytes)

Offen
#456 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
1.5k
Forks
220
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.