Caching data -fast performance

Posted on April 9, 2008. Filed under: Asp.net |

public class CacheSearch
{
    protected DataSet _ds;
    protected string ksearch;
  
 public CacheSearch()
 {  
 }
   
    public static DataSet GetAlldataCIdKeyid(int cid, int kid)
    {
        return GetAlldataCityIdKeyid(HttpContext.Current, cid, kid);
    }
protected static DataSet GetAlldataCityIdKeyid(HttpContext context, int cid, int kid)
    {
        string ksearchkey = “cachkey_” + cid.ToString() + “_” + kid.ToString();
        DateTime expiration = DateTime.Now.AddMinutes(10);
        DataSet allcidkey = context.Cache[ksearchkey] as DataSet;
        if (allcidkey == null)
        {
            allcidkey = KEYWORDSEARCH.keysearchcidkeyid(cid, kid);
            context.Cache.Add(ksearchkey, allcidkey, null, expiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);

        }
        return allcidkey;
    }

}

 

public class KEYWORDSEARCH
    {
public static DataSet keysearchcidkeyid(int cid, int keyid)
        {
            DATALAYER dl = new DATALAYER();
            dl.AddParameter(“@cid”, cid);
            dl.AddParameter(“@kid”, keyid);
            return dl.ExecuteDataSet(“getkeysearch”);
        }
  }

and codehind of page u write code which bind to datagrid
 DataSet ds = CacheSearch.GetAlldataCIdKeyid(cid,kid);

 this ds bind with datagrid  and show better performance

 

here Datalayer is connection class if u want to according ur need u change

Make a Comment

Make a Comment: ( None so far )

blockquote and a tags work here.

    About

    Hi,I am Suresh Sharma from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...