I want to use Jake Wharton's DiskLruCache for Android to cache CouchDb documents on disk. CouchDb ids are just any JSON String, so could look Sömething/Like/Thís
. However, the library's docs state
Each cache entry has a string key and a fixed number of values. Each key must match the regex
[a-z0-9_-]{1,64}
.
So I need a way to transform an arbitrary strings to conform to the regex [a-z0-9_-]{1,64}
, while still being unique. How can I do this elegantly?