Hi Peter.

>>But then you have to open it on every access and must synchronize the 
>>write-access on it, or use a background-process that manages it...
> 
> Yup that's the main issue here - you cannot have different instances
> open in different processes
> 
> Also I fear the it would be inefficient
> you would have to
> a) get a lock
> b) open the persistent object
> c) Move to the end
> d) append data
> e) save (transfer from ^CacheTemp to the persistent location)
> f) remove the lock
>:{
> 
> Also there may be issues with having a background process doing the
> work  cos the in-memory copy of the stream temporarly saves data to
> ^CacheTemp (by default) so the saved version might not be the current
> version
> 
> That's why I suggested a simpler method
> 
> So the key question is why do you need a stream???

that's the question!

Maybe its easier to write to a global:

ClassMethod WriteToUniqueStream(data As %String)
{
  s ^CacheTemp("UNIQUESTREAM",$i(^CacheTemp("UNIQUESTREAM"))=data
 // $i is important!
}

ClassMethod GetUniqueStream() as %BinaryStream
{
  s result=##class(%BinaryStream).%New()
  s key=""
  f {
    s key = $o(^CacheTemp("UNIQUESTREAM",key))
    q:key=""
    d result.Write(^CacheTemp("UNIQUESTREAM",key))
  } 
  q result

}

^Florian

Reply via email to