Hi all, 
I have implemented write-through using CacheStoreAdapter. The object being
inserted contains identity column in the database and as a so, generates
value in DB (this value is also my cache key). I have noticed that when
CacheStoreAdapter.Write(object key, object val) method is executed as a
result of Put operation (e.g. Id=-1 while calling Put), the entry is not in
the cache yet, while Write method is executed.

So the question is, can I somehow modify the key entry in WriteMethod to
assign Idenity value coming from DB ? Also is there a better way to Put
entries with idenity column (i.e. IGenerators) ? 

public override void Write(object key, object val)
        {
            Program.Log("Write " + key.ToString());
            var kpi = (val as IBinaryObject).Deserialize<KPIDetail>();
            int newKey = new KPIDetailsRepo().InsertOrUpdate(kpi);
        
            // at this point the given key is not in the cache yet. However
changing key or val object won't impact the value inserted into the cache
             key = newKey;
             val = (val as IBinaryObject).ToBuilder().SetField<int>("ID",
newKey).Build();
        }

Thanks



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-to-write-through-when-database-contains-identity-column-tp10412.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to