TsgcWSRateLimiter › Methods › LoadStateFromStream
Restores the internal state from an arbitrary TStream.
procedure LoadStateFromStream(aStream: TStream);
| Name | Type | Description |
|---|---|---|
aStream | TStream | Source stream positioned at the first byte produced by a previous SaveStateToStream call. Any TStream descendant is accepted. |
Clears all current state and rehydrates Token Bucket sizes, Sliding Window timestamps, Fixed Window counters, burst tracker state and quota counters from the stream. Use this overload (instead of LoadStateFromFile) when the saved state lives in a database BLOB, in shared storage or in memory. The caller owns the stream and is responsible for positioning it before the call and freeing it afterwards.
var
oMemStream: TMemoryStream;
begin
oMemStream := DownloadFromSharedStorage;
try
oMemStream.Position := 0;
sgcWSRateLimiter1.LoadStateFromStream(oMemStream);
finally
oMemStream.Free;
end;
end;