ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Mashenkov <andrey.mashen...@gmail.com>
Subject Re: How to write-through when database contains identity column
Date Fri, 03 Feb 2017 13:56:27 GMT
Hi david,

This will not work.
1. You can't replace key parameter as it passed by value.
2. Even it you do this somehow this will be wrong, due to Write() method
will be run on node that own partitions that old key belongs to by
affinity, but not the new key.

It looks like it is not supported. However you are free to implement custom
id generator [1]

[1] http://apacheignite.gridgain.org/docs/id-generator

On Fri, Feb 3, 2017 at 10:54 AM, davida <david.alezander@live.com> wrote:

> 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.

С уважением,
Машенков Андрей Владимирович
Тел. +7-921-932-61-82

Best regards,
Andrey V. Mashenkov
Cerr: +7-921-932-61-82

View raw message