Overview
TMCache is a powerful and flexible caching library for iOS and macOS applications. It provides an efficient and easy-to-use solution for caching data, reducing network requests, and optimizing the performance of your app.
Features
- Sync and async cache operations
- Supports both memory and disk caching
- Customizable cache expiry and size limits
- Automatic memory management and cleanup
- Thread-safe operation
Installation
To integrate TMCache into your iOS or macOS project, follow these steps:
- Using CocoaPods:
- Carthage:
- Manual installation:
“`
pod ‘TMCache’
“`
“`
github “tmblr/TMCache”
“`
Download the latest release from the GitHub repository. Drag and drop the TMCache folder into your Xcode project.
Usage
To start using TMCache in your project:
- Import the framework:
- Create a cache instance:
- Set and retrieve cached objects:
- Additional cache operations:
- Handle cache eviction:
“`
import TMCache
“`
“`
let cache = TMCache(name: “myCache”)
“`
“`
// Set an object in cache
cache.setObject(“Hello, world!”, forKey: “myKey”)
// Retrieve an object from cache
if let cachedObject = cache.object(forKey: “myKey”) as? String {
print(cachedObject)
}
“`
“`
// Remove object from cache
cache.removeObject(forKey: “myKey”)
// Clear all objects from cache
cache.removeAllObjects()
“`
“`
cache.setOnMemoryWarningBlock { cache in
// Perform cleanup or eviction logic here
cache.removeAllObjects()
}
“`
Contributing
We welcome and appreciate contributions from the community. To contribute to TMCache, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make necessary changes and commit your code.
- Submit a pull request.
License
TMCache is released under the Apache License 2.0. See LICENSE file for more details.
Contact
For any questions or concerns, you can reach us at info@example.com.