nhibernate/NHibernate-Caches

Key computing for Memcached leaks hashers

fredericDelaporte opened this issue · 0 comments

Both NHibernate-Caches MemCache and EnyimMemcached use a hash algorithm for computing keys when they exceed the maximal length supported by Memcached, 250.

They use a thread-static instance of HashAlgorithm, which is disposable. There is no way to properly dispose of them. They should be local variables instead.

Initially reported as:

Both NHibernate-Caches MemCache and EnyimMemcached use a non-thread safe algorithm for computing keys when they exceed the maximal length supported by Memcached, 250.

They use a static instance of HashAlgorithm, which is not thread safe. This may cause caching or retrieving values with unexpected keys. The HashAlgorithm instance must be a local variable of the function computing the key. (It cannot either be a non static field, since caches need to be thread safe.) No thread safety issue, they are stored as ThreadStatic variables.