Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

[IO] Add MemoryHandle #58

Closed
azjezz opened this issue Sep 26, 2019 · 4 comments
Closed

[IO] Add MemoryHandle #58

azjezz opened this issue Sep 26, 2019 · 4 comments

Comments

@azjezz
Copy link
Contributor

azjezz commented Sep 26, 2019

MemoryHandle is a read-write non-disposable handle that stores data in memory ( i.e. property private string $data = ''; ), unlike TemporaryFile which stores data in filesystem.

MemoryHandle would be more efficient when dealing with a small amount of data or for mocking HTTP Requests, files ... etc. since it doesn't touch the filesystem.

@azjezz
Copy link
Contributor Author

azjezz commented Sep 26, 2019

MemoryHandle probably should also be seekable, since its possible to seek a position for read/write here - related #43

@lexidor
Copy link
Contributor

lexidor commented Sep 27, 2019

Strong agree. It is something light to swap in during unit tests.

@fredemmott
Copy link
Contributor

Thanks; this is reasonable, but definitely something to visit after sockets are done: until then, I want to keep the number of concrete implementations limited to the ones that will shape the overall API design, especially given the huge amount of interfaces, traits, and classes needed to implement it.

If socket support reveals shortcomings in the current API design, we'd like to keep the number of things that need updating small. This also means that we're unlikely to accept a pull request until socket support is stable.

@azjezz
Copy link
Contributor Author

azjezz commented Oct 15, 2019

MemoryHandle implementation is available here : https://gist.github.com/azjezz/204575d521e68d8ed691934966fdbe35 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants