最新消息:

MemcachedKeyCharacterError: Control characters not allowed

memcached admin 3504浏览 0评论

对于想使用 MySQL 实现简单 ID 分配器, 一般就是设置一个整数字段, 然后想分配的时候加 1 并返回. 新手往往犯错误, 先执行一条 update 语句, 然后再 select 那个字段. 但这是错误的!

正确的方式应该是使用 last_insert_id() 函数:

update mytable set count=last_insert_id(counter+1);
select last_insert_id();

 

转载请注明:爱开源 » MemcachedKeyCharacterError: Control characters not allowed

您必须 登录 才能发表评论!