i try to use effective caching but i face to face a problem. For example; i have 5 user they have used my app. user1,2,3,4 only fill grid by searcing(Caching is run!!!). on the other hand user5 adding new row. i want to refresh my cach data when adding new row. i read Multi threading to do that
code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Collections;
namespace WebApp.Caching.Threading
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
FillCache();
}
void FillCache()
{
using (var myCtx = new DataClasses1DataContext())
{
if (!(FlyAntCache.Exists("test")))
{
List<Table_1> toolStoreList = myCtx.Table_1s.ToList();
FlyAntCache.Add(toolStoreList, "test");
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
WaitCallback method1 = new WaitCallback(ControlAllChanging);
bool isQueued = ThreadPool.QueueUserWorkItem(method1, new ManualResetEvent(false));
}
protected void ControlAllChanging(object state)
{
if (FlyAntCache.Exists("test"))
{
using (var myCtx = new DataClasses1DataContext())
{
List<Table_1> list;
list = myCtx.Table_1s.ToList();
List<Table_1> listCache = FlyAntCache.Get<List<Table_1>>("test");
bool IsIntersect = list.Except(listCache).Count() > 0;
if (IsIntersect)
{
FlyAntCache.Clear("test");
FillCache();
}
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
// Search
using (var myCtx = new DataClasses1DataContext())
{
var Qry = myCtx.Table_1s.
FromCache<Table_1>("test").
AsQueryable().Where(t => t.ad == TextBox1.Text.Trim());
GridView1.DataSource = Qry;
GridView1.DataBind();
}
}
}
}
My Scenario:
LOOK please :http://i53.tinypic.com/20pdc41.png

i really control if another user change my data, i must refresh my cache. is there any sensitivity to CAPTURE any new changing update new row save. for example : 1) i must capture new update . this mechanizm must run when changes occurs 2) i must capture new save. this mechanizm must run when new row adds