Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom disk cache and memory cache #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haifengkao
Copy link

I have moved DiskCache and NSCache to the arguments of the generic class Cache, which is a subclass of HanekeCache.
The users who want to customize DiskCache or NSCache can use HanekeCache with custom implementation (a subclass) of DiskCache and NSCache

}
}

public class HanekeCache<T: DataConvertible, DiskCacheT, MemoryCacheT where T.Result == T, T : DataRepresentable, DiskCacheT: DiskCache, MemoryCacheT: NSCache> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having MemoryCacheT: NSCache as generic constraint means that the memory cache must be a NSCache subclass, while subclassing NSCache might be not the main preference of a developer while building a custom memory caching system. I recommend to protocols DiskCache and MemoryCache to give complete implementation freedom to the developer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct. but I need someone to ensure that this PR is going to be merged before I spend time on this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fair. I'm not the maintainer so I cannot give you this guarantee, but the swift 4 branch was just merged.

@dcharbonnier
Copy link
Contributor

dcharbonnier commented Jan 30, 2018

if we can preserve compatibility I think there is good chances that we merge it
thx @gringoireDM for the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants