Can I specify cache key
I have an image and want it to be stored with a specific(custom) cache-key , so the image URI is different from the cache-key , can I do that?
We don't support that functionality at the moment. Can you give us some context on why do you need that?
Correction: we do support this. It's not yet in the docs, but maybe we should add it.
You can provide an implementation of the CacheKeyFactory interface when configuring the image pipeline. I would recommend subclassing DefaultCacheKeyFactory.
Use this feature with great caution. If you do it wrong, your app could be a lot slower or show the wrong images entirely.
Thanks :D
@tyronen , I am aware of that class, but I don't think this is what @mohammedhammouri need. If I understood correctly, he wants to use a custom key on per request basis, not a mechanism for different uri mapping. CacheKeyFactory is intended for mapping image requests to their cache keys based on their uri and possible other options. Uri normalization is one possible use case. However there is currently no option in our image request to use a custom key, which means that the key will have to be derived from the uri to avoid collisions which then means that whole this effort of writting a custom CacheKeyFactory is useless as you still need the uri. I might have misunderstood the question though.
@mohammedhammouri, can you give us more context on what are you trying to achieve?
OK @plamenko , every time I get a url from the server the url changes even for the same image because of the expiration time so I have to save the image without the expire time in cache also save the url for it in db too (where I have all of the cached images urls), then when I want to get image from cache or from server(if it's deleted from cache) I set the url that I get from server,so I don't have to first specify the full key(with expire time)and see if it's failed(not exists in the cache) then load one from server because the url I get from server expires after a period.
Ex : here is the string that I get from the server : HTTP_Verb + "\n" + Content_MD5 + "\n" + Content_Type + "\n" + Expiration + "\n" + Canonicalized_Extension_Headers + Canonicalized_Resource;
http://google-testbucket.storage.googleapis.com/testdata.txt?GoogleAccessId=1234567890123@developer.gserviceaccount.com&Expires=1331155464&Signature=BClz9e4UA2MRRDX62TPd8sNpUCxVsqUDG3YGPWvPcwN%2BmWBPqwgUYcOSszCPlgWREeF7oPGowkeKk7J4WApzkzxERdOQmAdrvshKSzUHg8Jqp1lw9tbiJfE2ExdOOIoJVmGLoDeAGnfzCd4fTsWcLbal9sFpqXsQI8IQi1493mw%3D;
"&Expires=1331155464" this change every time.
Oh, in that case Tyrone's answer should help you :)
Yup , but it would be very nice if we can specify , delete cache as we need .. not from a factory.