-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Class with @RedisHash and byte[] property is turned into Map<String, Byte> #1981
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
Comments
Generally speaking, the performance of Do you want me to create a PR for that part? It may not be the optimal solution, but it does the job much better. A second change will be needed in order to read
|
We'd be happy to review a PR. |
By using a TreeMap, entries starting with a certain prefix can be found much faster than before. Related tickets spring-projects#1981
You're right, I didn't understand the full logic of the existing implementation. The unit tests pass for my submitted PR. |
It would make sense to consider I'd be generally fine with tweaking the representation as of the next feature release. Any objections @christophstrobl? |
fine with me. |
I discovered that if you define a class with @RedisHash and a byte[] property, one key-value pair is stored for each byte.
Here's some example code:
When an object of this class is stored in Redis using a
CrudRepository<MyClass, String>
, the Redis content will look like this:When you then use
findById
on the repository,Bucket.extract()
will be called byMappingRedisConverter.readCollectionOrArray()
for each key, leading to about 16 millionString.startsWith()
calls.In my opinion, the
byte[]
should be stored as aString
value, not as aMap<String, Byte>
.Replacing the byte[] with a String reduced the run time of my webservice operation from 1200 ms to 45 ms.
The text was updated successfully, but these errors were encountered: