-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
166 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Sources/GoogleScholarSwift/Models/GoogleScholarCacheConfig.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Foundation | ||
import SwiftSoup | ||
|
||
/// A configuration object for the cache settings in `GoogleScholarFetcher`. | ||
public struct GoogleScholarCacheConfig { | ||
public let publicationCountLimit: Int | ||
public let publicationTotalCostLimit: Int | ||
public let articleCountLimit: Int | ||
public let articleTotalCostLimit: Int | ||
|
||
/// Default cache configuration. | ||
public static let `default` = GoogleScholarCacheConfig( | ||
publicationCountLimit: 100, | ||
publicationTotalCostLimit: 1024 * 1024 * 10, | ||
articleCountLimit: 100, | ||
articleTotalCostLimit: 1024 * 1024 * 5 | ||
) | ||
|
||
/// Initializes a new cache configuration. | ||
/// | ||
/// - Parameters: | ||
/// - publicationCountLimit: Maximum number of publications to cache. | ||
/// - publicationTotalCostLimit: Maximum total cost of publications in the cache. | ||
/// - articleCountLimit: Maximum number of articles to cache. | ||
/// - articleTotalCostLimit: Maximum total cost of articles in the cache. | ||
public init( | ||
publicationCountLimit: Int, | ||
publicationTotalCostLimit: Int, | ||
articleCountLimit: Int, | ||
articleTotalCostLimit: Int | ||
) { | ||
self.publicationCountLimit = publicationCountLimit | ||
self.publicationTotalCostLimit = publicationTotalCostLimit | ||
self.articleCountLimit = articleCountLimit | ||
self.articleTotalCostLimit = articleTotalCostLimit | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters