One. First with Redis.
Http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2011/0406/7873.html
I have a good address for myself.
<appSettings> <add key= "Redisurl" value= "10.10.4.50:7895"/>//Domain name <add key= "Redisdata" value= "/>//value=12" is the 12th library </appSettings>
Write CS file
public static class Redispool {public static Pooledredisclientmanager poolreds; static int port = Convert.ToInt32 (configurationmanager.appsettings["Redisdata"]. ToString ()); Static Redispool () {try {poolreds = new Pooledredisclientmanager (port, new S Tring[] {configurationmanager.appsettings["Redisurl"]}); } catch (Exception ex) {//publicfunction.log ("" + Ex. Message + "\ r \ n"); PublicFunction.Log ("" + Ex. StackTrace + "\ r \ n"); }}///<summary>//cache to Redis///</summary>//<param name= "key" > </param>//<param name= "danhaolist" ></param> public static void Enqueuelist (string key, String obj) {using (var client = poolreds. Getclient ()) {//queue using if (obj! = null) { Client. Additemtolist (key, obj); }//client. ADD (key, obj); }}///<summary>//Read current///</summary>/<param name= "key" ></ param>//<returns></returns> public static string Dequeuemodel (String key) { using (var client = poolreds. Getclient ()) {string Danhao = client. Getitemfromlist (key,0); return Danhao; }}///<summary>//To determine whether there is a record currently///</summary>//<param name= "key" > </param>///<returns></returns> public static long GetListCount (string key) { using (var client = poolreds. Getclient ()) {Long Count = client. GetListCount (key); return count; }}///<summary>//clear Redis Data///</summary> <returns></returns> public static void Popredis () {using (var client = Poolreds . Getclient ()) {client. FLUSHDB ();//Clear Redis Data}}}
The foreground call.
Redispool.enqueuelist ("Lin" +datetime.now.tostring ("Yyyy-mm-dd"), DateTime.Now.ToString ()); Label1. Text = "hits Yesterday:" + Redispool.getlistcount ("Lin" + DateTime.Now.AddDays (-1). ToString ("Yyyy-mm-dd")); Label2. Text = "Hits Today:" + Redispool.getlistcount ("Lin" + DateTime.Now.ToString ("Yyyy-mm-dd"));
Cache to Redis record data