Question
· 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
Discussion (6)3
Log in or sign up to continue

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

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: