About %Stream.TmpCharacter
Dear, Community!
I have a concern about using %Stream.TmpCharacter for storage purposes. Reading the class's source code, I can understand a bit about how it works. But I'd like to know from the community how it actually works. Is it necessary to use the .Clear() method to clear this buffer, or is it done automatically upon disposal?
Note: Please forgive my poor English.
Comments
%Stream.TmpCharacter is appropriate for temporary storage that does not persist data and automatically deletes data when the object goes out of scope. %Stream.FileBinary, on the other hand, creates and maintains a file on the disk explicitly, persisting its data permanently until manually deleted. This persistence can increase disk I/O compared to shorter-lived object memory operations. Both options serve different purposes based on whether data persistence is desired [1][2].
If your objective is only to log data temporarily, %Stream.TmpCharacter may be more efficient as it avoids creating permanent files and involves less I/O overhead [1].
Sources:
Hello @Matheus Augusto
%Stream.TmpCharacter is used to temporarily hold stream data in IRIS for application usage, typically in-memory and not persisted to the database.
Reading the class implementation, you can see that it does not write to memory, but in ^CacheStream, my concern is how this allocation is managed.
Read the class code of %Stream.TmpCharacter Method %OnNew()
and you see ^CacheStream is the default if no other Global uses in %New,
example: ....set stream=##class(%Stream.TmpCharacter).%New("^||temp.Stream")
would store it in a process private global (NO JOURNAL!) just during your session
or ^mtemp,Stream writes it to IRISTEMP also without JOURNAL:
Correct! I just want to know if I need to manage the disposal of this temporary or if the class itself does it for me.
the PPG ^||... is deleted latest by termination or the partion
the ^mtemp* will be killed by reboot of IRIS.
As both are not under your direct control better KILL it manually
PPG ^||.. is more promising being bound to process
as it has less risk of concurrency issues