TsgcWSRateLimiterProperties › StorageFile

StorageFile Property

Optional file path used by the state-persistence methods.

Syntax

property StorageFile: string read FStorageFile write FStorageFile;

Default Value

Remarks

Stores the file path used by SaveStateToFile and LoadStateFromFile. Setting this property does not persist or restore state automatically — the application must still call the save/load methods at the right moments (typically LoadStateFromFile at startup and SaveStateToFile at shutdown, or periodically from a timer). Persisting counters across restarts ensures a rolling Token Bucket continues refilling from where it stopped instead of starting fresh and accepting a huge burst after every restart.

Example

sgcWSRateLimiter1.StorageFile := 'ratelimit.dat';
sgcWSRateLimiter1.LoadStateFromFile(sgcWSRateLimiter1.StorageFile);
// ... later, on shutdown:
sgcWSRateLimiter1.SaveStateToFile(sgcWSRateLimiter1.StorageFile);

Back to Properties