+
+# A shared cache for serialization and deserialization
+class DuplexCache
+ super SerializerCache
+ super DeserializerCache
+
+ redef fun new_id_for(object)
+ do
+ var id = super
+ received[id] = object
+ return id
+ end
+
+ redef fun []=(id, object)
+ do
+ super
+ assert object isa Serializable
+ sent[object] = id
+ end
+end
+
+# A shared cache where 2 clients serialize objects at the same types, prevents references collision
+class AsyncCache
+ super DuplexCache
+
+ # Should this end use even numbers?
+ var use_even: Bool
+
+ private var last_id: Int is lazy do return if use_even then 0 else 1
+
+ redef fun next_available_id
+ do
+ last_id += 2
+ return last_id
+ end
+end