http://jira.grails.org/browse/GRAILS-10364

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

http://jira.grails.org/browse/GRAILS-10364

Jeff Scott Brown-2
I think the problem is that the toString() of the resource is being used when the cache key is generated which is obviously problematic.  I am looking at solutions.  I think using the system identity hash code is problematic because when the same entity is retrieved from the datastore it won’t always be the same instance and we could end up with lots of keys for the same entity.  I have not done testing but I suspect that trying to inspect the object to get the identifier if it exists might be more expensive than just not caching, especially if we don’t assume that the identifier is named “id".  I wonder if we should rig up the isCacheable method in CachingLinkGenerator to not cache if the resource attribute is specified.

What say ye?



JSB

--
Jeff Scott Brown
[hidden email]

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: http://jira.grails.org/browse/GRAILS-10364

Lari Hotari -

GormInstanceApi adds "Serializable ident()" method to GORM domain classes. I think that could be used to get the id of GORM class instances.

ident() spec:
https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/GormEnhancerSpec.groovy#L107

There is only one usage of "ident()" in grails:
https://github.com/grails/grails-core/blob/master/grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/FormTagLib.groovy#L943

Lari


06.12.2013 14:32, Jeff Scott Brown wrote:
I think the problem is that the toString() of the resource is being used when the cache key is generated which is obviously problematic.  I am looking at solutions.  I think using the system identity hash code is problematic because when the same entity is retrieved from the datastore it won’t always be the same instance and we could end up with lots of keys for the same entity.  I have not done testing but I suspect that trying to inspect the object to get the identifier if it exists might be more expensive than just not caching, especially if we don’t assume that the identifier is named “id".  I wonder if we should rig up the isCacheable method in CachingLinkGenerator to not cache if the resource attribute is specified.

What say ye?



JSB

--
Jeff Scott Brown
[hidden email]

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email