Skip to content

Is it reasonable to generate cache key of collection object without any warnings? #53

@steadiest

Description

@steadiest

I saw many people using collection object as a key of ReadThroughSingleCache attached method,
they would be intended to use ReadThroughMultiCache which generates a collection of keys and invokes the multi-get command.

This kind of mistake can lead to unexpected consequences,

  • cache key of a big collection will cause communication error by exceeding allowed memcached key length.
  • dispersity of cache key increases unexpectedly - cache key will be varied when order or size are changed. And it can make the user think that SSM seems not working well.

It could be good to warn in 2 ways.

  • emit warning logs
  • or throw InvalidAnnotationException to let them know the key is inappropriate

I wrote this issue after looking at source code below
https://github.com/ragnor/simple-spring-memcached/blob/master/simple-spring-memcached/src/main/java/com/google/code/ssm/aop/support/CacheKeyMethodStoreImpl.java

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions