同事下午遇到一问题,MySQL 和 Memcached 对于同一个key,不能对应起来。最终原因是:PHP将key写入MySQL数据库之前,没有经过trim()过滤首尾空格(关键是尾部空格),结果:

  1、MySQL的varchar、char类型字段,SELECT .... WHERE 查询时忽略字段的尾部空格。例如varchar类型字段uidcode中,存储的含有尾部空格的内容“rewinx ”,通过以下三种方式均可查询到:

  点击在新窗口中浏览此图片

  在MySQL手册第“11.4.1. CHAR和VARCHAR类型”节中写道(http://dev.mysql.com/doc/refman/5.1/zh/column-types.html#char):请注意所有MySQL校对规则属于PADSPACE类。这说明在MySQL中的所有CHAR和VARCHAR值比较时不需要考虑任何尾部空格。请注意所有MySQL版本均如此,并且它不受SQL服务器模式的影响。



  2、PHP 的 Memcache 扩展,则在set、get时,自动将key中的空格,转换成了半角下划线“_”。当然,直接通过 Memcached 协议来读取,key值“rewinx ”就要写成“rewinx_”了。

  示例:testmc.php
  点击在新窗口中浏览此图片






技术大类 » Cache与存储 | 评论(44) | 引用(0) | 阅读(36724)
12
2011-1-30 14:23
msyql有空和没有空不一样吧,前两天刚刚遇到这个问题,误多写了一个空格,查出记录为0
碧青海
2011-3-28 11:47
ttserver有没有忽略大小写的配置功能??
louis vuitton uk Email Homepage
2011-11-22 17:11
This louis vuitton uk for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this coach outlet store online. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine christian louboutin sale. Purse the elegance in bridal wedding. Enjoy the fashion.
armani watches Email Homepage
2011-11-23 10:12
If you are looking for armani Bags, our armani watches Handbags Canada outlet store is your first choice. We promise Original Packing and Best Discount,3-5 Workdays To Your Door!If you buy bags and purses of the latest new designs from the louis vuitton outlet now, you can enjoy special discounts. What else are you waiting for?After you choose the right kind of plants and the size pot for the plant.
muzhiwan Email
2011-12-12 21:59
OOPS....
wedding520 Email Homepage
2011-12-27 15:52
ワイドネックライン、'V'ネックやボートネックラインは、一般にキャップスリーブとドレスのために選ばれている。ボートスタイルのネックラインと幅広いネックラインのためには、オフショルダーのキャップスリーブを追加することができます。オフショルダーのウエディングドレスは、数年以来、結婚式の摩耗で人気のパターンになっても流行で、今日でもあります。カラードレス 格安.のこのスタイルで素敵に見える模様のオフショルダーの袖に行く同じシースのサテンからステッチ/オフショルダーのキャップスリーブの上に薄いと飾ったときに裾フレアのビットとシースのサテンのイブニングドレスとスパゲッティネックラインがすごい見えます。
Hogan Homepage
2012-5-10 17:51
Ci sono diversi motivi principali per cui si può sicuramente trovare sul proprio volere le soluzioni contabili che coinvolgono tutta Stansted, anche se alcune persone potrebbero uomini e donne, probabilmente si dovrà disporre di soluzioni contabili rispetto con la gente. Stai con me per scoprire di più su molti dei motivi per prendere in considerazione l'impiego contabili in tutta Hogan Stansted. Costruire un businessIf vi capita di essere in funzione, è abbastanza possibile che si può fare uso di soluzioni contabili. Non date per scontato tutte le società hanno abbastanza soldi per utilizzare a tempo pieno il personale fiscali, così utilizzando una conditi insieme con l'agenzia affidabile che coinvolge tutta commercialisti Stansted potrebbe rendere meno difficili problemi.
hogan280 Email
2012-5-10 18:04
Nella segnalazione del Rochdale "processo grooming" molto è stato fatto del fatto che gli uomini erano in gran parte pakistani, mentre Hogan le 47 vittime, anche se solo sette hanno fornito prove - erano tutti bianchi e classe operaia. Le vittime avevano un'età compresa tra 13 e 15 anni al momento dell'abuso, e la polizia li ha descritti come da "caotica" e "Consiglio tenuta" sfondi.
virginiag Email Homepage
2012-7-26 10:03
Popular The North Face Jackets with the low price sale on online. If you want to buy the jackets that The North Face Outlet has discount for you. And we have other series for customers. http://www.northfaceoutletchicago.com/
lirourou77 Email Homepage
2012-9-5 13:22
in a new mechanism of system to replace the old in medicine have medical mechanism, which is the cheap designer handbags      
cattle nets", and click "online voting" found that, the original vote is paid, 1 yuan 1 ticket.

"If you have to vote online, by pay treasure, net silver or cell phone pays fee." HeXianSheng cheap designer clothes        
said, let people will choose the doctors like this is a good thing, but if will pay it is stale, "so, mean who's money, who can election?"

【 operation 】 can buy tickets into batch quantity
discount designer handbags        

According to HeXianSheng provide web site, reporter found "purple cattle nets", "popular activities" column in the article 1 is: ningxiang county "open the door the medical" advanced unit and "top ten doctors, top ten nurses, top ten technicians" selection activities to officially wholesale designer handbags
asdfas
2013-7-23 15:32
细节有时候确实很重要
磨延城 Email Homepage
2013-10-21 20:37
磨途歌学习了
Steven Email Homepage
2015-3-19 02:30
Thank you for this post Weight Loss Tea
dssfs Email Homepage
2015-3-20 05:38
应用公园 Email Homepage
2015-12-24 17:11
应用公园提供的是一种APP在线制作服务,也就是说用户通过应用公园可以自行制作app软件,根据自身的需求,选择合适的模板添加app素材,就可制作出一个专业的且可是运营的,还可以通过后台对应用内容进行管理。
http://zyan.cc/mysql_memcached_space/
2021-4-12 12:55
Thanks for the information on this. I really enjoy the information. google
Paulojimmathew Email
2021-7-29 12:33
Your site got my attention and shows me different perception for how we should boost our site. This is a really perfect for a new blogger like me who doesn't want their site to be messy with those spammers who don't even read your post but they have the guts to comment in your site. Thanks again.  เว็บบาคาร่ายอดนิยม
Ieuan Ventura Email
2021-10-20 18:01
An organization’s long-term victory will depend on the execution of its workers. I believe you have already yours. Maybe you also lift my side.  เกมสล็อต
分页: 2/3 第一页 上页 1 2 3 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]