Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 32947200CA4 for ; Wed, 7 Jun 2017 11:43:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 31181160BE2; Wed, 7 Jun 2017 09:43:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A85FD160BB6 for ; Wed, 7 Jun 2017 11:43:20 +0200 (CEST) Received: (qmail 64968 invoked by uid 500); 7 Jun 2017 09:43:14 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 64958 invoked by uid 99); 7 Jun 2017 09:43:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2017 09:43:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4B9C8D0165 for ; Wed, 7 Jun 2017 09:43:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id VLxJ9rcT0JaH for ; Wed, 7 Jun 2017 09:43:11 +0000 (UTC) Received: from mail-qt0-f177.google.com (mail-qt0-f177.google.com [209.85.216.177]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 583A25F6C8 for ; Wed, 7 Jun 2017 09:43:11 +0000 (UTC) Received: by mail-qt0-f177.google.com with SMTP id u19so4093254qta.3 for ; Wed, 07 Jun 2017 02:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=eXzdfyg7/kAPo4kJoIQGb/YSL1JVyjnKRuGmRMpO9Zo=; b=oTlYkPmgc9MuCwBg9YHae4/9HYUGhfXS4gA/sSEzBP+9iRkZXMvdDfrOhLfSTnwvJn a0/K2FAJw2yWrGgPq3DsbmsII7Lb0UX4cS74vjtSXCc2PNhK2EWSDtM6C2bfuONlOBEi +lR3jafWzsLrcwBHGqh4iOauJzmqaBPMq1kxUcgYg4QTzZe2HC+gK6E+xYqTASiaYdNA YWdP7FxrGB8CPPttx2iBTtd6RR3YXK3AbFYpXxUzBgYm00uCa80N+QGe1WokcWuP6dvX dgyya8cmi8vVUwJ1rokj9rGQJRq4xlepZIM6dXz2XEs/6wzBmooaVEiml1FLeL8mKM5Z cUAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=eXzdfyg7/kAPo4kJoIQGb/YSL1JVyjnKRuGmRMpO9Zo=; b=MgvfzZIgFqtxfHvW0dDc8sHu4LobD2K1TQfvh9fv79wi1hfq9PqO4r2WVEfxNyc9wO celhUESPrQMq5p00dn3nQUbAeiWdE49ItonZPAyPj7zsfpEMiE8Xf2NixLm2WUHhJ5bK yblJ4cuAFAqShnoxCWS93PXNy5ynkxTwFq0VYuForC9ZM/N5Rut5LHNgXqrKfxGYZYA8 M/JP0tg5mZy7sEaErRZQuJGv4c8cNDh84XFZmdCcLROQIMy9rLPNgn7FQFhKhBAJu2TM tPYg3YlrYLCETj34yekQjltBZLd0xkJak1MHdNE8TJTSyvpuqATqaWsaR/pn6cFPRL9S J2lA== X-Gm-Message-State: AODbwcALSJjl9E5IFtf1Xpp+MoftoaFgrY9gGDAqc+GzgkFMrXY01WSw 3kJjQ2lGxY/mrgBxC3DpzN50uw7c/ER/ X-Received: by 10.200.47.210 with SMTP id m18mr31495157qta.187.1496828590765; Wed, 07 Jun 2017 02:43:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.37.48 with HTTP; Wed, 7 Jun 2017 02:43:10 -0700 (PDT) In-Reply-To: References: From: Chetan D Date: Wed, 7 Jun 2017 15:13:10 +0530 Message-ID: Subject: Re: update existing cache To: user@ignite.apache.org, Pavel Tupitsyn Content-Type: multipart/alternative; boundary="001a1142adba713b9c05515b9095" archived-at: Wed, 07 Jun 2017 09:43:22 -0000 --001a1142adba713b9c05515b9095 Content-Type: text/plain; charset="UTF-8" also i am doing this and got the following error dont know what it is. SqlCommand cmd = new SqlCommand("select Name,Power from Cars", con); con.Open(); rdr = cmd.ExecuteReader(); #region using put List directcar = new List(); while (rdr.Read()) { directcar.Add(new car(rdr["Name"].ToString(), Convert.ToDouble(rdr["Power"]))); } cache.Put(2, directcar); got this exception Apache.Ignite.Core.Cache.Store.CacheStoreException was unhandled HResult=-2146233088 Message=class org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException: Failed to update keys (retry update if possible).: [2] Source=Apache.Ignite.Core StackTrace: at Apache.Ignite.Core.Impl.PlatformTarget.DoOutInOpX(Int32 type, Action`1 outAction, Func`2 inErrorAction) at Apache.Ignite.Core.Impl.Cache.CacheImpl`2.DoOutOp[T1,T2](CacheOp op, T1 x, T2 y) at Apache.Ignite.Core.Impl.Cache.CacheImpl`2.Put(TK key, TV val) at Addtableentirely.Program.Main(String[] args) in C:\Users\M1029218\Documents\Visual Studio 2015\Projects\Apacheignite\Addtableentirely\Program.cs:line 106 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: HResult=-2147467262 Message=Unable to cast object of type 'System.Collections.Generic.List`1[Addtableentirely.car]' to type 'Addtableentirely.car'. Source=Apache.Ignite.Core StackTrace: at Apache.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignite.Core.Impl.Binary.IBinarySerializerInternal.ReadBinary[T](BinaryReader reader, IBinaryTypeDescriptor desc, Int32 pos) at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadFullObject[T](Int32 pos) at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res) at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T]() at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadBinaryObject[T](Boolean doDetach) at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res) at Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T]() at Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadObject[T]() at Apache.Ignite.Core.Impl.Cache.Store.CacheStoreInternal`2.Invoke(IBinaryStream stream, Ignite grid) at Apache.Ignite.Core.Impl.Cache.Store.CacheStore.Invoke(PlatformMemoryStream stream, Ignite grid) at Apache.Ignite.Core.Impl.Unmanaged.UnmanagedCallbacks.CacheStoreInvoke(Int64 memPtr) InnerException: On Wed, Jun 7, 2017 at 3:08 PM, Chetan D wrote: > Hi Pavel, > > I got that its easy when there is a key with value but my requirement is > such that i need to store all values of table with single key associated. > > The code which you sent is not working and doesnt give any error as well. > > you have sent it in case when an update happens. > > my question is when a new record has been added and that new record i need > to insert it to cache. > > and also i have a column in my table in which i have updated say in this > case name value to something else so i need to update that corresponding > value in cache as well. > > > can you tell me the difference between cache.getandreplace() and > cache.getandput() they both are doing same thing actually. > > > > it would be helpfull if i can get answer with respect to list storage. > > On Wed, Jun 7, 2017 at 2:34 PM, Pavel Tupitsyn > wrote: > >> Hi Chetan, >> >> I'm not sure about #1 and #3 - why do you add all entities as a list with >> a single key? Typically this is not how Ignite is used. >> Proper way is to add each entity (Car) as a separate cache entry, with >> unique key (id), like in #2. >> >> As soon as you have all data in cache, each Car with a unique id, and you >> have an SQL listener set up, event handler can look like this: >> >> static void Changed(object sender, RecordChangedEventArgs e) >> { >> var ignite = Ignition.GetIgnite(); >> var cache = ignite.GetCache("cars"); >> >> switch (e.ChangeType) >> { >> case ChangeType.Update: >> cache.Put(e.ID, e); >> break; >> case ChangeType.Delete: >> cache.Remove(e.ID); >> break; >> } >> } >> >> Let me know if this makes sense. >> >> Thanks, >> Pavel >> >> >> On Wed, Jun 7, 2017 at 11:41 AM, Chetan D wrote: >> >>> Hi Pavel, >>> >>> I am using the same car program which you have written in blog and i >>> have some doubts on that. >>> >>> I have the following scenarios which i have doubts on. >>> >>> 1.#region using put >>> List directcar = new List(); >>> while (rdr.Read()) >>> { >>> directcar.Add(new car(rdr["Name"].ToString(), >>> Convert.ToDouble(rdr["Power"]))); >>> } >>> cache.Put(1, directcar); >>> #endregion put >>> Here i am creating a cache and adding list of values with a single key >>> >>> 2.Using data streamer >>> //using (var ldr = ignite.GetDataStreamer(cacheCfg.Name)) >>> //{ >>> // //ldr.PerNodeBufferSize = 1024; >>> >>> >>> // while (rdr.Read()) >>> // { >>> // ldr.AddData((int)rdr[0], new >>> car(rdr["Name"].ToString(),Convert.ToDouble(rdr["Power"]))); >>> >>> // Console.WriteLine("LDR" + ldr.ToString()); >>> >>> // } >>> >>> //} >>> here i am using datastreamer and adding each values with a key >>> >>> 3. #region adding all elements as list with single key using get >>> datastremer >>> using (var ldr = ignite.GetDataStreamer>> List>(cacheCfg.Name)) >>> { >>> List cars = new List(); >>> >>> while (rdr.Read()) >>> { >>> cars.Add(new car(rdr["Name"].ToString(), >>> Convert.ToDouble(rdr["Power"]))); >>> } >>> ldr.AddData(1, cars); >>> Console.WriteLine("LDR" + ldr.ToString()); >>> >>> } >>> #region reading from cache >>> foreach (ICacheEntry> car in cache) >>> { >>> foreach (car cars in car.Value) >>> { >>> Console.WriteLine(cars.ToString()); >>> } >>> Console.WriteLine(car.Value.ToList()); >>> >>> >>> } >>> #endregion >>> here i am using data streamer to add list of values with a single key. >>> >>> so now when this application is running and all the cache data has been >>> loaded i have added a new record in my table. >>> >>> so for that i have added a listener like this >>> >>> var mapper = new ModelToTableMapper(); >>> mapper.AddMapping(c => c.ID, "ID"); >>> mapper.AddMapping(c => c.Name, "Name"); >>> mapper.AddMapping(c => c.Power, "Power"); >>> mapper.AddMapping(c => c.IsAvailable, "IsAvailable"); >>> >>> >>> >>> using (var dep = new SqlTableDependency(ad.sqlconnection, >>> "Cars", mapper)) >>> { >>> dep.OnChanged += Changed; >>> dep.Start(); >>> >>> Console.WriteLine("Press a key to exit"); >>> Console.ReadKey(); >>> >>> dep.Stop(); >>> } >>> #endregion >>> static void Changed(object sender, RecordChangedEventArgs e) >>> { >>> if (e.ChangeType != ChangeType.None) >>> { >>> var changedEntity = e.Entity; >>> Console.WriteLine("DML operation: " + e.ChangeType); >>> Console.WriteLine("ID: " + changedEntity.ID); >>> Console.WriteLine("Name: " + changedEntity.Name); >>> Console.WriteLine("Power: " + changedEntity.Power); >>> Console.WriteLine("IsAvailable: " + >>> changedEntity.IsAvailable); >>> >>> Console.WriteLine("<---------- >>> ------------------------------------------------------------ >>> ---------------->"); >>> } >>> >>> so my question is when a new record has been added to my table i get a >>> event triggered and will get the value which is inserted. >>> >>> so now how to add the new value to existing cache say by using >>> datastreamer which works on list i need to add this row to end of list in >>> existing cache. >>> >>> Delete >>> when record is deleted i get a event and i need to delete that record >>> from existing cache. >>> >>> Update >>> when a column of table is updated say NAME column i need to update that >>> particular column value in cache. >>> >>> can you please help me how to implement this. >>> >>> } >>> >> >> > --001a1142adba713b9c05515b9095 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
also i am doing this = and got the following error dont know what it is.

SqlCommand cmd =3D new SqlCommand("select Name,Po= wer from Cars", con);
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 con.Open();=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rdr =3D cmd.ExecuteReader();
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 #region using put
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 List<car>= directcar =3D new List<car>();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = while (rdr.Read())
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 directcar.Add(new car(rdr["Name"].ToString(), Convert.ToDo= uble(rdr["Power"])));
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(2, directcar);

got this exception=C2=A0
Apache.Ignite.Core.Cache.Store.CacheStoreException w= as unhandled
=C2=A0 HResult=3D-21= 46233088
=C2=A0 Message=3Dclass o= rg.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedExcepti= on: Failed to update keys (retry update if possible).: [2]
=C2=A0 Source=3DApache.Ignite.Core
=C2=A0 StackTrace:
=C2=A0 =C2=A0 =C2=A0 =C2=A0at Apache.Ignite.Core.Impl.Platfo= rmTarget.DoOutInOpX(Int32 type, Action`1 outAction, Func`2 inErrorAction)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at Apac= he.Ignite.Core.Impl.Cache.CacheImpl`2.DoOutOp[T1,T2](CacheOp op, T1 x, T2 y= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0at A= pache.Ignite.Core.Impl.Cache.CacheImpl`2.Put(TK key, TV val)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at Addtableentirely.= Program.Main(String[] args) in C:\Users\M1029218\Documents\Visual Studio 20= 15\Projects\Apacheignite\Addtableentirely\Program.cs:line 106
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.AppDomain= ._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.AppDomain.E= xecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] arg= s)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at = Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.Threa= ding.ThreadHelper.ThreadStart_Context(Object state)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.Threading.Execution= Context.RunInternal(ExecutionContext executionContext, ContextCallback call= back, Object state, Boolean preserveSyncCtx)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.Threading.ExecutionContext= .Run(ExecutionContext executionContext, ContextCallback callback, Object st= ate, Boolean preserveSyncCtx)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0at System.Threading.ExecutionContext.Run(ExecutionC= ontext executionContext, ContextCallback callback, Object state)
=C2=A0 =C2=A0 =C2=A0 =C2=A0at System.Thread= ing.ThreadHelper.ThreadStart()
= =C2=A0 InnerException:
=C2=A0 =C2= =A0 =C2=A0 =C2=A0HResult=3D-2147467262
=C2=A0 =C2=A0 =C2=A0 =C2=A0Message=3DUnable to cast object of type &#= 39;System.Collections.Generic.List`1[Addtableentirely.car]' to type = 9;Addtableentirely.car'.
=C2= =A0 =C2=A0 =C2=A0 =C2=A0Source=3DApache.Ignite.Core
=C2=A0 =C2=A0 =C2=A0 =C2=A0StackTrace:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apa= che.Ignite.Core.Impl.Binary.BinaryReflectiveSerializerInternal.Apache.Ignit= e.Core.Impl.Binary.IBinarySerializerInternal.ReadBinary[T](BinaryReader rea= der, IBinaryTypeDescriptor desc, Int32 pos)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.= Impl.Binary.BinaryReader.ReadFullObject[T](Int32 pos)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Ig= nite.Core.Impl.Binary.BinaryReader.TryDeserialize[T](T& res)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 a= t Apache.Ignite.Core.Impl.Binary.BinaryReader.Deserialize[T]()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 at = Apache.Ignite.Core.Impl.Binary.BinaryReader.ReadBinaryObject[T](Boolean doD= etach)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.Impl.Binary.BinaryReader.TryDeseria= lize[T](T& res)
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.Impl.Binary.BinaryReader= .Deserialize[T]()
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.Impl.Binary.BinaryReader.= ReadObject[T]()
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.Impl.Cache.Store.CacheStoreI= nternal`2.Invoke(IBinaryStream stream, Ignite grid)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 at Apache.Igni= te.Core.Impl.Cache.Store.CacheStore.Invoke(PlatformMemoryStream stream, Ign= ite grid)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 at Apache.Ignite.Core.Impl.Unmanaged.UnmanagedCallback= s.CacheStoreInvoke(Int64 memPtr)
= =C2=A0 =C2=A0 =C2=A0 =C2=A0InnerException:


On Wed, Jun 7, 2017 at = 3:08 PM, Chetan D <cchetands@gmail.com> wrote:
Hi Pavel,

I got = that its easy when there is a key with value but my requirement is such tha= t i need to store all values of table with single key associated.

The code which you sent is not working and doesnt give any = error as well.

you have sent it in case when an up= date happens.

my question is when a new record has= been added and that new record i need to insert it to cache.
and also i have a column in my table in which i have updated sa= y in this case name value to something else so i need to update that corres= ponding value in cache as well.


can= you tell me the difference between cache.getandreplace() and cache.getandp= ut() they both are doing same thing actually.


=

it would be helpfull if i can get answer with res= pect to list storage.

On Wed, Jun 7, 2017= at 2:34 PM, Pavel Tupitsyn <ptupitsyn@apache.org> wrote:=
Hi Chetan,

I'm not sure about #1 and #3 - why do you add all entities as a = list with a single key? Typically this is not how Ignite is used.
Proper way is to add each entity (Car) as a separate cache entry, with uni= que key (id), like in #2.

As soon as you have all = data in cache, each Car with a unique id, and you have an SQL listener set = up, event handler can look like this:

static = void Changed(object sender, RecordChangedEventArgs<Car> e)
= {
=C2=A0 =C2=A0 var ignite =3D Ignition.GetIgnite();
= =C2=A0 =C2=A0 var cache =3D ignite.GetCache<int, Car>("cars"= ;);

=C2=A0 =C2=A0 switch (e.ChangeType)
= =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case ChangeType.Updat= e:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(e.ID, e);<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0= =C2=A0 =C2=A0 =C2=A0 case ChangeType.Delete:
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 cache.Remove(e.ID);
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 }
}

Let me know if this makes sense.

Thanks,
Pavel


On Wed, Jun 7, 2017 at 11:4= 1 AM, Chetan D <cchetands@gmail.com> wrote:
H= i Pavel,

I am using the same car program which you have writt= en in blog and i have some doubts on that.

I have the followi= ng scenarios which i have doubts on.

1.#region using put
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 List<= car> directcar =3D new List<car>();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 while (rdr.Read())
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 directcar.Add(new car(rdr["Name"].ToString(), Convert.= ToDouble(rdr["Power"])));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cache.Put(1, directcar);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #endregion put
Here i am creating a cache and adding list of values with a s= ingle key

2.Using data stream= er
=C2=A0//using (var ldr =3D ign= ite.GetDataStreamer<int, car>(cacheCfg.Name))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 //{
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // //ldr.PerNodeBuf= ferSize =3D 1024;
=C2=A0
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // while (rdr.Read())
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // ldr.AddData((int)rdr[0], new car(rdr[&qu= ot;Name"].ToString(),Convert.ToDouble(rdr["Power"])));<= /div>
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 // Console.WriteLine("LDR" + ldr.ToString());
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // }
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 //}
here i = am using datastreamer and adding each values with a key

3. #region adding all elements as list with sing= le key using get datastremer
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 using (v= ar ldr =3D ignite.GetDataStreamer<int, List<car>>(cacheCfg.Name= ))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 List<car> cars =3D new List<car>();
<= div style=3D"box-sizing:border-box;max-width:100%;color:rgb(51,51,51);font-= family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px= ;background-color:rgb(250,250,250)">=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 while (rdr.Read())
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 cars.Add(new car(rdr["Name"].ToString(), Convert.ToDou= ble(rdr["Power"])));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ldr.AddD= ata(1, cars);
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.= WriteLine("LDR" + ldr.ToString());
=C2=A0
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 #region reading from cache
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 foreach (ICacheEntry<int, List<car>> car in cache)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 foreach (car cars in car.Value)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 Console.WriteLine(cars.ToString());
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 Console.WriteLine(car.Value.ToList());
=C2=A0
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #endregion
here i am using data streamer to a= dd list of values with a single key.

so now when this application is running and all the cache data has = been loaded i have added a new record in my table.

so for that i have added a listener like this

=C2=A0var mapper =3D new ModelToTabl= eMapper<car>();
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mapper.AddMapping(c =3D> c= .ID, "ID");
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mapper.AddMapping(c =3D> c= .Name, "Name");
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mapper.AddMapping(c =3D>= ; c.Power, "Power");
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mapper.AddMapping(c= =3D> c.IsAvailable, "IsAvailable");
=C2=A0
=C2=A0
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 using= (var dep =3D new SqlTableDependency<car>(ad.sqlconnection, &quo= t;Cars", mapper))
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 dep.OnChanged +=3D Changed;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= dep.Start();
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 Console.WriteLine("Press a key to exit")= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.ReadKey();
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dep.= Stop();
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #endregion
=C2=A0 static void Changed(object sender= , RecordChangedEventArgs<car> e)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 if (e.ChangeType !=3D ChangeType.None)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 var changedEntity =3D e.Entity;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Consol= e.WriteLine("DML operation: " + e.ChangeType);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 Console.WriteLine("ID: " + changedEntity.ID);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Console.WriteLine("Name: " + changedEntity.Name);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 Console.WriteLine("Power: " + changedEntity.= Power);
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.WriteLine("IsAvailable: &= quot; + changedEntity.IsAvailable);
=C2=A0
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Console.WriteLine("<------------------------------------------------------------------------= -------------->");
}

<= /div>
so my question is when a new reco= rd has been added to my table i get a event triggered and will get the valu= e which is inserted.

so now h= ow to add the new value to existing cache say by using datastreamer which w= orks on list i need to add this row to end of list in existing cache.
=

Delete
when record is deleted i get a event and i need to delete th= at record from existing cache.
Update
when a column of table i= s updated say NAME column i need to update that particular column value in = cache.

can you please help me= how to implement this.
=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 }



--001a1142adba713b9c05515b9095--