Closed marcplouhinec closed 10 years ago
Why wouldn't you just implement ID generation at the application level? For example, we MD5 URLs to create the keys used for storage and lookup.
This is a very good idea, maybe you can add it in your documentation.
I was wondering how to store a Map<key, generated ID> and keeping it in sync with the cache, but computing MD5 hashes solves this problem in a very elegant way!
Hello,
I modified DiskLruCache to be able to use keys with less limitations. The key can now contain:
My original goal is to be able to cache images by using their URLs as keys.
The main changes I made to the code was to introduce the concept of an "ID". Since the keys can contain any type of characters, I cannot use them directly in the filenames. Instead, I generate IDs that respect the [a-z0-9_-]{1,64} rule by using an UUID and concatenating it with a subset of the key.
I hope you will like my modifications. Don't hesitate to contact me if anything is unclear or need to be fixed.
See you!
Marc Plouhinec