Written by

Developer
Question Matheus Augusto · Sep 4

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.

Product version: Caché 2018.1

Comments

DC AI Bot · Sep 4 Bot

%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:

0
Ashok Kumar T · Sep 4

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.

0
Matheus Augusto  Sep 4 to Ashok Kumar T

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.

0
Robert Cemper  Sep 4 to Matheus Augusto

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:
 

0
Matheus Augusto  Sep 4 to Robert Cemper

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.

0
Robert Cemper  Sep 4 to Matheus Augusto

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

0