Under the first use of nhibernate, fancy its level two cache, but found not to turn on the cache, the data is normal, once opened to find a lot of duplicate data, I tried the two cache implementations of NHibernate.Caches.MemCache and NHibernate.Caches.EnyimMemcached, and found that the bug was the same, and that using the nhibernate comes with the NHIBERNATE.CACHE.HASHTABL The Ecacheprovider cache implementation was found to be normal, so I guess it was a duplicate of the generated key, because Memcache (I use the Windows version) key can not be more than 250, so the extra long key will definitely be hashed, I used the anti-compilation tool to key out the NHibernate.Caches.MemCache code to debug it is really a lot of key hash into the same, such as the following two key:
Key1:
Edu.db:[email protected]:/* Criteria query */SELECT this_. newsclassify_id as newsclas1_11_0_, This_. Newsclassify_name as newsclas2_11_0_, This_. Newsclassify_path as newsclas3_11_0_, This_. Newsclassify_state as newsclas4_11_0_, This_. Newsclassify_icon as newsclas5_11_0_, This_. Newsclassify_parent as newsclas6_11_0_ from Newsclassify this_ WHERE this_. Newsclassify_name =? and This_. Newsclassify_state =?; Parameters: []; Named parameters: {' cp0 ' = ' The Application for study abroad ', ' cp1 ' = ' 1 '}; First row:0
Key2:
Edu.db:[email protected]:/* Criteria query */SELECT this_. newsclassify_id as newsclas1_11_0_, This_. Newsclassify_name as newsclas2_11_0_, This_. Newsclassify_path as newsclas3_11_0_, This_. Newsclassify_state as newsclas4_11_0_, This_. Newsclassify_icon as newsclas5_11_0_, This_. Newsclassify_parent as newsclas6_11_0_ from Newsclassify this_ WHERE this_. Newsclassify_name =? and This_. Newsclassify_state =?; Parameters: []; Named parameters: {' cp0 ' = ' doctoral student application ', ' cp1 ' = ' 1 '}; First row:0
The above two keys only the end of a few Chinese slightly different, the results are scattered into the bmrpnkl2zgfqs6v1butpo2rzr+4=, this repetition is too high (although the hash is inevitable)
I prepared the code deduction, the hash key place with MD5 encryption re-implementation, should be able to, the specific code is not sent, because no few code, I send this essay is to reflect this phenomenon.
NHibernate third-party level two cache bug