Is this in some way wrong or an appropriate attemp...
# coroutines
d
Is this in some way wrong or an appropriate attempt to set the cache to maxed?
Copy code
val sharedFlow = MutableSharedFlow<String> = MutableSharedFlow(replay = Int.MAX_VALUE)
d
use case?
j
If you need to replay every value ever emitted, maybe you should consider a cold flow instead? Where does the data of this flow come from?
g
Looks like an easy way to get unexpected OOM
d
@Dominaezzz OK, let's assume your application uses event sourcing to persist data. On Startup we build a projection from all events and also want to push these events to a client via server sent events. So every time a client (subscriber) subscribes to the shared flow I want all events that we received before, be "replayed" for the client. Hope it makes sense?
g
Should instead those events be persisted first and every client subscribe and request required amount of events when it’s needed from storage, not from mermory, instead persist all of them in memory and hope that it will be persisted by some code later and before OOM
j
..or before a server restart
d
Well, sure you can max out the cache (...ish, if there's no buffer space) but just beware of OOM as has been said above.
d
OK, but nothing special, besides OOM, which I already had in my mind as harmful! THX