Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
Created August 15, 2025 12:13
Show Gist options
  • Save jacobsapps/28b70decf79efb4ccc27b6bc56febf35 to your computer and use it in GitHub Desktop.
Save jacobsapps/28b70decf79efb4ccc27b6bc56febf35 to your computer and use it in GitHub Desktop.
var purgeCacheTask: Task<Void, Never>?
func setupCacheTTL() {
purgeCacheTask?.cancel()
purgeCacheTask = Task(priority: .low) {
try? await Task.sleep(for: .seconds(300))
guard !Task.isCancelled else { return }
cache.clear()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment