ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Tupitsyn <ptupit...@apache.org>
Subject Re: update existing cache
Date Thu, 08 Jun 2017 08:58:41 GMT
Make sure that ICache and ICacheStore generic types match, looks like you
have List<car> in cache but ICacheStore<int, car>

Pavel


On Thu, Jun 8, 2017 at 9:31 AM, Chetan D <cchetands@gmail.com> wrote:

> yes i tried with try catch and the same message i got.
>
> Apache.Ignite.Core.Cache.Store.CacheStoreException was unhandled by user
> code
>   HResult=-2146233088
>   Message=class org.apache.ignite.transactions.TransactionRollbackException:
> Transaction has been rolled back: 48906b28c51-00000000-0674-db36
> -0000-000000000001
>   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.Changed(Object sender,
> RecordChangedEventArgs`1 e) in C:\Users\M1029218\Documents\Visual Studio
> 2015\Projects\Apacheignite\Addtableentirely\Program.cs:line 260
>   InnerException:
>        HResult=-2146233088
>        Message=Transaction has been rolled back:
> 48906b28c51-00000000-0674-db36-0000-000000000001
>        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.Unmana
> ged.UnmanagedCallbacks.CacheStoreInvoke(Int64 memPtr)
>             InnerException:
>
> On Wed, Jun 7, 2017 at 10:01 PM, Pavel Tupitsyn <ptupitsyn@apache.org>
> wrote:
>
>> That is strange, can you wrap it in try-catch block and print out
>> ex.ToString()?
>> How many nodes do you have?
>>
>> On Wed, Jun 7, 2017 at 5:46 PM, Chetan D <cchetands@gmail.com> wrote:
>>
>>> Hi Pavel,
>>>
>>> That is the full stack trace
>>>
>>> On Jun 7, 2017 7:00 PM, "Pavel Tupitsyn" <ptupitsyn@apache.org> wrote:
>>>
>>>> Hi Chetan, is that full stack trace?
>>>>
>>>> Pavel
>>>>
>>>> On Wed, Jun 7, 2017 at 4:20 PM, Chetan D <cchetands@gmail.com> wrote:
>>>>
>>>>> Hi Pavel,
>>>>>
>>>>> I have implemented Lock but got following exception.
>>>>>
>>>>> using (var cacheLock = cache.Lock(1))
>>>>> {
>>>>>     cacheLock.Enter();
>>>>>     List<Car> cars = cache.Get(1);
>>>>>     cars.Add(newCar);
>>>>>     cache.Put(1, cars);-------------------------->exception here
>>>>>     cacheLock.Exit();
>>>>> }
>>>>>
>>>>> Apache.Ignite.Core.Cache.Store.CacheStoreException was unhandled by
>>>>> user code
>>>>>   HResult=-2146233088
>>>>>   Message=class org.apache.ignite.transactions.TransactionRollbackException:
>>>>> Transaction has been rolled back: 48906b28c51-00000000-0674-db36
>>>>> -0000-000000000001
>>>>>   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.Changed(Object sender,
>>>>> RecordChangedEventArgs`1 e) in C:\Users\M1029218\Documents\Visual
>>>>> Studio 2015\Projects\Apacheignite\Addtableentirely\Program.cs:line 260
>>>>>   InnerException:
>>>>>        HResult=-2146233088
>>>>>        Message=Transaction has been rolled back:
>>>>> 48906b28c51-00000000-0674-db36-0000-000000000001
>>>>>        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.Unmana
>>>>> ged.UnmanagedCallbacks.CacheStoreInvoke(Int64 memPtr)
>>>>>             InnerException:
>>>>>
>>>>>
>>>>> On Wed, Jun 7, 2017 at 5:33 PM, Pavel Tupitsyn <ptupitsyn@apache.org>
>>>>> wrote:
>>>>>
>>>>>> > my requirement is such that i need to store all values of table
>>>>>> with single key associated
>>>>>> How many values do you plan to store in a single Ignite entry?
>>>>>> Typically you have one Ignite cache entry for one DB row.
>>>>>>
>>>>>> >  when a new record has been added and that new record i need
to
>>>>>> insert it to cache
>>>>>> So you in Ignite you have a mapping from int to List<Car>,
right?
>>>>>> ICache<int, List<Car>>?
>>>>>> If you need to insert a new Car into that list atomically, you can
do
>>>>>> that within a cache lock:
>>>>>>
>>>>>> using (var cacheLock = cache.Lock(1))
>>>>>> {
>>>>>>     cacheLock.Enter();
>>>>>>     List<Car> cars = cache.Get(1);
>>>>>>     cars.Add(newCar);
>>>>>>     cache.Put(1, cars);
>>>>>>     cacheLock.Exit();
>>>>>> }
>>>>>>
>>>>>> > difference between cache.getandreplace() and cache.getandput()
>>>>>> GetAndReplace does not do anything if there is no entry with
>>>>>> specified key.
>>>>>> GetAndPut always has effect: either creates new entry or updates
>>>>>> existing
>>>>>>
>>>>>>   cache.GetAndReplace(1, "");
>>>>>>   cache.ContainsKey(1); // False
>>>>>>   cache.GetAndPut(2, "");
>>>>>>   cache.ContainsKey(2); // True
>>>>>>
>>>>>>
>>>>>> > Unable to cast object of type 'System.Collections.Generic.List`1[Addtableentirely.car]'
>>>>>> to type 'Addtableentirely.car'
>>>>>> Your cache store implementation is ICacheStore<int, car> while
there
>>>>>> is List<car> value in cache.
>>>>>> Change the cache store to ICacheStore<int, List<car>>
>>>>>>
>>>>>> >  the issue is when i do the above code it is again actually
calling
>>>>>> my icachestore method WRITE() and the data is again added to database
table
>>>>>> To avoid this use WithSkipStore method:
>>>>>> cache.WithSkipStore().Put(e.Entity.ID,new car(e.Entity.Name,
>>>>>> e.Entity.Power));
>>>>>>
>>>>>> Here you have ICache<int, car> again instead of List<car>,
by the
>>>>>> way. Have you decided to go this way instead?
>>>>>>
>>>>>>
>>>>>> > $bin/ignite.sh but its not working
>>>>>> For .NET please use
>>>>>> platforms\dotnet\bin\Apache.Ignite.exe
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Pavel
>>>>>>
>>>>>> On Wed, Jun 7, 2017 at 2:08 PM, Chetan D <cchetands@gmail.com>
wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I need one more help can you tell me how to start ignite node
>>>>>>> without using Visual studio.
>>>>>>>
>>>>>>> i have seen this command
>>>>>>>
>>>>>>> $bin/ignite.sh
>>>>>>>
>>>>>>> but its not working
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Jun 7, 2017 at 4:29 PM, Chetan D <cchetands@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi Pavel,
>>>>>>>>
>>>>>>>> when a new record has been added to DB i have handled it
through
>>>>>>>> event and i was able to add it to cache
>>>>>>>> like this
>>>>>>>> var ignite = Ignition.GetIgnite();
>>>>>>>>             var cache = ignite.GetCache<int, car>("cars");
>>>>>>>>             cache.Put(e.Entity.ID,new car(e.Entity.Name,
>>>>>>>> e.Entity.Power));
>>>>>>>>
>>>>>>>> but the issue is when i do the above code it is again actually
>>>>>>>> calling my icachestore method WRITE() and the data is again
added to
>>>>>>>> database table.
>>>>>>>>
>>>>>>>> On Wed, Jun 7, 2017 at 3:13 PM, Chetan D <cchetands@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> 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<car> directcar = new List<car>();
>>>>>>>>>                     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.pro
>>>>>>>>> cessors.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.Hosting
>>>>>>>>> Process.HostProc.RunUsersAssembly()
>>>>>>>>>        at System.Threading.ThreadHelper.ThreadStart_Context(Object
>>>>>>>>> state)
>>>>>>>>>        at System.Threading.ExecutionCont
>>>>>>>>> ext.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.Unmana
>>>>>>>>> ged.UnmanagedCallbacks.CacheStoreInvoke(Int64 memPtr)
>>>>>>>>>        InnerException:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 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 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 <
>>>>>>>>>> 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 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<Car>
e)
>>>>>>>>>>> {
>>>>>>>>>>>     var ignite = Ignition.GetIgnite();
>>>>>>>>>>>     var cache = ignite.GetCache<int, Car>("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 <cchetands@gmail.com>
>>>>>>>>>>> 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<car> directcar
= new List<car>();
>>>>>>>>>>>>                     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<int,
>>>>>>>>>>>> car>(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<int, List<car>>(cacheCfg.Name))
>>>>>>>>>>>>                     {
>>>>>>>>>>>>                         List<car> cars
= new List<car>();
>>>>>>>>>>>>
>>>>>>>>>>>>                         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<int,
List<car>> 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<car>();
>>>>>>>>>>>>                 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<car>(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<car> 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.
>>>>>>>>>>>>
>>>>>>>>>>>>             }
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>
>

Mime
View raw message