JakeWharton / DiskLruCache

Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.
http://jakewharton.github.io/DiskLruCache
Apache License 2.0
5.79k stars 1.18k forks source link

Allow keys with dashes (-) so one can use the return of an object's .hashCode() as key #24

Closed jonasfa closed 11 years ago

jonasfa commented 12 years ago

Useful for HTTP caching and other cases.

For instance:

URL url = new URL("http://host/path");
String myKey = String.valueOf(url.hashCode()); // may be a negative integer
jonasfa commented 12 years ago

Just updated the README.md file. Somehow ack found the regex occurences on src/ but not on README.md.

jonasfa commented 12 years ago

Let me know if there's anything keeping you from merging this change.

jonasfa commented 12 years ago

@JakeWharton it's been a month now since you last replied. Is there anything pending for this pull request to be accepted/merged?

swankjesse commented 12 years ago

If you really want to use a hash code for a key, use Integer.toHexString() rather than converting it to a string in the regular way. You won't get any negative signs that way.

jonasfa commented 12 years ago

@swankjesse Thank you! Hadn't thought of Integer.toHexString().

Bdiang commented 12 years ago

I used UUID as a key with 1.1.0 and can't change it :/ Why dash in key is not allowed anymore?

JakeWharton commented 11 years ago

Hmmm. @swankjesse think we should re-allow dashes? Don't see any reason against it, myself.

Bdiang commented 11 years ago

I would be very appreciate!

swankjesse commented 11 years ago

Yeah, for UUIDs alone this is a good idea.