Comments (5)
Hm, this indeed sounds a bit strange. I've not experienced this.
AwesomeCache uses NSCoding
and NSKeyedArchiver
to persist objects under the hood.
Could you try and persist the picture using NSKeyedArchiver
to try and see if the persisted object is of similar size?
from awesomecache.
I'll try that tomorrow.
When I inspected the cached binary I saw NSKeyedArchiver
annotations already. Maybe this problem is also specific to JPEG files. Will investigate further tomorrow.
from awesomecache.
NSKeyedArchiver
will persist the uncompressed UIImage
and that's why you see the difference in size compared to the JPEG file. You would need to cache the data returned by UIImageJPEGRepresentation
.
from awesomecache.
@mbuchetics Good point! Thanks a lot, that makes sense and I just changed our implementation accordingly:
Use NSData
as cached type:
struct Images {
static let cache = Cache<NSData>(name: "images")
}
Writing to cache:
if let data = UIImageJPEGRepresentation(processedImage, 0.6) {
Images.cache.setObject(data,
forKey: imageId,
expires: cacheExpiry)
}
Reading from cache:
if let imageData = Images.cache[imageId] {
return UIImage(data: imageData)
}
Now file sizes are under 1MB. Issue can be closed then. Keep up the good work!
from awesomecache.
@mbuchetics Thanks for the clarification.
@MattesGroeger Awesome, if you have further questions feel free to reopen. 🎇
from awesomecache.
Related Issues (20)
- Caching for Swift 3 's data type HOT 1
- Memory Peak during removeExpiredObjects
- Remove Entire Cache
- Saving array of Custom Object
- Swift 4 support HOT 5
- Cache timeout much sooner than expected HOT 2
- Swift 5 Support
- Carthage install fails
- Please put up a disclaimer that this project is abandoned
- why its written swift 3.0 support , when it is not working ???? HOT 4
- Carthage build error
- Is usable to cache downloaded files ? HOT 1
- Error - Version 3.0.1 is Swift 2.3 HOT 3
- Can CacheBlockClosure and ErrorClosure block be @escaping? HOT 1
- Performance issue when removeExpiredObjects HOT 1
- Pod update error HOT 1
- not triggering "cacheBlock" on API Caching HOT 2
- Cache video url - then get it from cache again? HOT 1
- How to get Expired Object If Present Only?
- AwesomeCache breaks UI Test Bundle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesomecache.