microsoft / ManagedEsent

MIT License
242 stars 36 forks source link

Keys are at most 2000 bytes but limit is not enforced #27

Open PietheinHeemskerk opened 5 years ago

PietheinHeemskerk commented 5 years ago

When you add items with long keys (I used ODATA Urls as key which can become quite long) it is acceptable to add keys longer than 2000 bytes. The AllKeys also works fine. However when you use Contains or TryGetValue then this key cannot be found. After some source code inspection it turned out that there is a constant Microsoft.Isam.Esent.Interop.KeyMostMost with a value of 2000 so the Cache class does not work properly. A possible fix would be to change the debug check in the Microsoft.Isam.Esent.Interop.MemoryCache.Duplicate method should be enforced at runtime.

michaelthorp commented 4 years ago

The key limitation is with the underlying database and has been there for a very long time. Unfortunately, I don't think it will change anytime soon so the 2000 byte limit will remain.

PietheinHeemskerk commented 4 years ago

The key limitation is with the underlying database and has been there for a very long time. Unfortunately, I don't think it will change anytime soon so the 2000 byte limit will remain.

I'm fine with the 2000 byte limit and did not request for any change in that limit.

I would like to have this limit enforced e.g. when constructing a PersistentBlob. If the number of bytes passed in is more than 2000 then it should throw an ArgumentException since the cache behavior will become inconsistent as stated in the original description.

michaelthorp commented 4 years ago

Ah, I see now. I'll take a look and try to fix that.