Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MemcacheºÍMsSQL½»»¥Á÷³Ìͼ


MemcacheºÍMsSQL½»»¥Á÷³Ìͼ
ÈçÉÏͼ£¬´«Í³µÄ²éѯ·½·¨ÊÇÖ±½Ó²éѯÊý¾Ý¿â£¬Êý¾Ý¿â½«½á¹û·µ»Ø¸ø²éѯÓï¾ä£¬¶øµ±ÓÐMemcacheÖм仺´æ²ãʱ£¬²éѯµÄÊÇMemcache»º´æÊý¾Ý£¬ÏÂÃæÏêϸÁ˽âMemcache¸÷ÀàÊý¾Ý²Ù×÷Ô­Àí£º
1£¬²éѯÊý¾Ý(select)£¬Ê×ÏÈͨ¹ýÖ¸¶¨µÄKey²éѯ(get)MemcacheÖм仺´æ²ãÊý¾Ý£¬Èç¹û´æÔÚÏà¶ÔÓ¦Êý¾Ý£¬ÔòÖ±½Ó»ñÈ¡³öÊý¾Ý½á¹û£¬²éѯ¹ý³ÌÍêÈ«²»ÐèÒª²éѯÊý¾Ý¿â¡£Èç¹û²»´æÔÚ£¬Ôò²éѯMsSQLÊý¾Ý¿â£¬²¢ÒÔkey¶ÔÓ¦valueµÄÐÎʽ½«²éѯ½á¹û´æ´¢ÔÚMemcache»º´æÊý¾ÝÖУ¬È»ºó½«½á¹û·µ»Ø¸ø²éѯÓï¾ä¡£
2£¬¸üÐÂÊý¾Ý(update)£¬Ê×ÏȸüÐÂÊý¾Ý£¬È»ºóɾ³ýÏà¹ØµÄmemcacheÊý¾Ý(delete)¡£
3£¬Ôö¼ÓÊý¾Ý(add)£¬Ê×ÏÈɾ³ýÏà¹Ø»º´æÊý¾Ý£¬È»ºóÔö¼ÓÊý¾Ý¡£
4£¬É¾³ýÊý¾Ý(delete)£¬É¾³ýÊý¾Ý£¬²¢É¾³ýMemcacheÊý¾Ý¡£
 
 
¶ÔMsSQLµÄÊý¾Ý²Ù×÷£¬Ö÷ÒªÉæ¼°µ½µÄMemcache·½·¨ÈçÏ£º
1£¬»ñÈ¡£ºget(key)
2£¬ÉèÖãºset(key, value [, expiry])
3£¬É¾³ý£ºdelete(key [, time])
ʵÀý£º
¼ÙÉèÒ»¸öÌù×Ó£¬»ñÈ¡Ìù×ÓIDΪ2009µÄÖµ£¬ÆäMemcacheÓëMsSQL½»»¥Á÷³ÌÈçÏ£º
string key = "sky";//keyǰ׺
int cachetime = 100;//»º´æÓÐЧʱ¼ä(Ãë)
string id = "2009";
Memcache»ù±¾²Ù×÷¹ý³Ì
1£¬²éѯ£ºresult = get(key+id);Èç¹ûresultΪ¿Õ£¬Ôò²éѯMsSQLÊý¾Ý¿â£¬È»ºóset(key+id,value,0,cachetime)
2£¬¸üУºÖØÐÂset
3£¬Ôö¼Ó£ºsetеÄkey
4£¬É¾³ý£ºdelete(key+id);


Ïà¹ØÎĵµ£º

½²½âMSSQLÊý¾Ý¿âÖÐSQLËø»úÖƺÍÊÂÎñ¸ôÀ뼶±ð

Ëø»úÖÆ
NOLOCKºÍREADPASTµÄÇø±ð¡£
1. ¿ªÆôÒ»¸öÊÂÎñÖ´ÐвåÈëÊý¾ÝµÄ²Ù×÷¡£
BEGIN TRAN t
INSERT INTO Customer
SELECT 'a','a'
2. Ö´ÐÐÒ»Ìõ²éѯÓï¾ä¡£
SELECT * from Customer WITH (NOLOCK)
½á¹ûÖÐÏÔʾ"a"ºÍ"a"¡£µ±1ÖÐÊÂÎñ»Ø¹öºó£¬ÄÇôa½«³ÉΪÔàÊý¾Ý¡£(×¢:1ÖеÄÊÂÎñδÌá½») ¡£NOLOCK±íÃ÷ûÓжÔÊý¾Ý±íÌí¼Ó¹²Ï ......

ÓÃ×÷ҵʵÏÖ×Ô¶¯±¸·ÝMSSQLÊý¾Ý¿âµ½Ô¶³Ì·þÎñÆ÷

--´Ë´úÂëʵÏÖSQLÊý¾Ý¿âÔ¶³Ì±¸·Ý£¬·Åµ½×÷ÒµÀïÃæÖ´ÐпÉÒÔ×Ô¶¯±¸·ÝÊý¾Ý¿â¡¢×Ô¶¯É¾³ý@keepNDaysÌìÇ°±¸·Ý¡£
--´Ë´úÂ뽫±¾µØËùÓеÄÓû§Êý¾Ý¿â±¸·Ýµ½¹²ÏíĿ¼¡°\\backupServerIp\ShareName\Êý¾Ý¿â±¸·Ý¡±Ï¡£
--²¢É¾³ýÌìÇ°µÄ±¸·ÝÎļþ¡£Òª±¸·Ý³É¹¦±ØÐëÄܹ»¶Ô¹²ÏíĿ¼ÓвÙ×÷ȨÏÞ£¡

sp_configure 'xp_cmdshell',1 ......

ÆôÓÃMSSQL·Ö²¼Ê½ÊÂÎñµÄ³£¼ûÎÊÌâ

ÈçºÎ´´½¨Á´½Ó·þÎñÆ÷
IF  EXISTS (SELECT srv.name from sys.servers srv WHERE srv.server_id != 0 AND srv.name = N'Á´½Ó·þÎñÆ÷Ãû')
EXEC master.dbo.sp_dropserver @server=N'Á´½Ó·þÎñÆ÷Ãû'', @droplogins='droplogins'
GO
EXEC master.dbo.sp_addlinkedserver
 @server = N'Á´½Ó·þÎñÆ÷Ãû'', @srvproduct= ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ