-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make cache types serialization friendly #1776
Make cache types serialization friendly #1776
Conversation
Implement |
Should we bother supporting xml serialization at all? XML adds a big overhead to the data size, it is an ill suited format for caching in my opinion. |
That is not possible, if you try that you will get an exception:
For me the first three are all fine, keeping the
Not really, I've added the |
Number 3 please |
2 or 3. Keeping the |
Then 3 it is. |
Stupid "GitHub-flavored markdown", I did not mean to write in bold my previous comment. What I meant is "Number 3 please". But, because because hash followed by a number would be interpreted as a issue/pr number. And because hash was the first character of the line it has been interpreted as a header. |
@@ -11,7 +11,7 @@ public class StructuredCollectionCacheEntry : ICacheEntryStructure | |||
public virtual object Structure(object item) | |||
{ | |||
var entry = (CollectionCacheEntry)item; | |||
return new List<object>(entry.State); | |||
return new List<object>((object[])entry.DisassembledState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the //TODO: assumes all collections disassemble to an array!
has moved here indeed.
@@ -8,7 +8,7 @@ public class StructuredMapCacheEntry : ICacheEntryStructure | |||
public object Structure(object item) | |||
{ | |||
CollectionCacheEntry entry = (CollectionCacheEntry)item; | |||
object[] state = entry.State; | |||
object[] state = (object[])entry.DisassembledState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the
//TODO: assumes all collections disassemble to an array!
has moved here indeed.
And here too. Then why not keeping it in the CollectionCacheEntry
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I got confused as IPersistentCollection.InitializeFromCache
and IPersistentCollection.Disassemble
are using object
which I think it should be changed to object[]
in the future as all implementations are casting/returning it.
Here is an attempt to make the serialization of cache types easier in order to support other serializers like
XmlSerializer
,DataContractSerializer
and others. I've added WIP in the title as the current tests are failing because of types that don't have a proper cacheable representation, which is covered by #1765. There is a limitation when aXmlSerializer
is used as it does not supportDateTimeOffset
andTimeSpan
types, which I wouldn't worry too much asDataContractSerializer
should be the preferred serializer for xml as it is faster.