Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use disk:getCacheKey()must match regex [a-z0-9_-]{1,64}: #3

Open
captain-miao opened this issue Jul 17, 2013 · 6 comments
Open

use disk:getCacheKey()must match regex [a-z0-9_-]{1,64}: #3

captain-miao opened this issue Jul 17, 2013 · 6 comments

Comments

@captain-miao
Copy link

07-17 21:36:36.430 11625-11625/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalArgumentException: keys must match regex [a-z0-9_-]{1,64}: "#W0#H0http://img.nian.so/dream/3_1364733573.jpg!dream"
at com.jakewharton.disklrucache.DiskLruCache.validateKey(DiskLruCache.java:660)
at com.jakewharton.disklrucache.DiskLruCache.get(DiskLruCache.java:406)
at com.dahuo.nian.net.images.DiskLruImageCache.getBitmap(DiskLruImageCache.java:108)

@dieselsaurav
Copy link

Getting same issue, anybody got the DiskCaching working??

@rdrobinson3
Copy link
Owner

I wrote this when Volley was first announced (before there was a lot of documentation available). The approach using the disk cache really isn't recommended as Volley is in fact disk caching images for you. I have some misgivings about the Volley documentation and its configurability but it should suit in most cases. I wrote a blog detailing the new findings some time ago: http://www.thekeyconsultant.com/2013/06/update-volley-image-cache.html .

I apologize for the confusion here. Also, I am working on a fix for the broken key generation. Essentially you just need to generate a key value that fits the criteria listed in the log. Check out the createKey function in the ImageCacheManager.

@az4mxl
Copy link

az4mxl commented Jan 16, 2014

The createKey function in the ImageCacheManager doesn‘t used!

@ewhite-dev
Copy link

@AZ-xml two things:

  1. Yes that function doesn't get called because the disklruimagecache does not use imagecachemanager so you have to add the createKey function to the disklruimagecache class and change two lines "snapshot = mDiskCache.get( key );" to "snapshot = mDiskCache.get( createKey(key) );" and "editor = mDiskCache.edit( key );" to "editor = mDiskCache.edit( createKey(key) );" , so that is the necessary patch

  2. No, this will not solve your performance problems because JakeWharton's DiskLruCache blocks and will make your listview adapter load slow and jerky. @rdrobinson3 has since decided to use Volley's own internal disk caching. This example project should be updated because it is very misleading and the memory cache does not solve out of memory errors on its own

@1hakr
Copy link

1hakr commented Mar 18, 2014

I have created a disk cache based on DiskLruCache and it works. It also solves the performance as its L2 cache and not L1 cache. You are welcome to try it out. Hope it helps.
https://github.com/DWorkS/VolleyPlus

@psycodex
Copy link

Working perfectly thx, Only thing is to change on line 106 of DiskLruImageCache to
snapshot = mDiskCache.get( key );
to
snapshot = mDiskCache.get( String.valueOf(key.hashCode()));
and on line 70
editor = mDiskCache.edit( key );
to
editor = mDiskCache.edit( String.valueOf(key.hashCode()));

Issue is happening because the key coming from volley library is basically string containing # and uppercase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants