ankitpokhrel / ankitpokhrel/tus-php

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

Abierto
#456 2 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
1.5k
Forks
220
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.