数据查询用了memcache缓存,用sql做的键值,分页数据不变
数据查询用了memcache缓存,用sql做的键值,传递分页的参数 sql就会产生变化 如果没有数据 就会重新查询并缓存 但是现在遇到这样一个问题 我在本地测试没有问题 但是传到服务器以后 无论传递什么参数 sql 是随之变化的 但是依据变化的键值 获得的数据列表并不跟着变化 请教一下大家可能是什么原因
回复讨论(解决方案)
怎????
如果你?的是一?字符串,不可能?的,?查下代?。
看看是否?自?加上??那些??。
是不是服务器数据就那么几条 不用分页啊? 导致每页数据都一样。。
贴出关键代码。
怎????
如果你?的是一?字符串,不可能?的,?查下代?。
看看是否?自?加上??那些??。
贴出关键代码。
$sql = "select id,avg_point,name,xpoint,ypoint,agent_area_id,area_id,supplier_id,index_img,dp_count,avg_point,deal_cate_id,ratio,area_id,note from aa where 1 = 1 and is_effect=1 and city_id in (18,1) order by id DESC limit 0,15"; $key = $GLOBALS['append_config']['IOS_CACHE_PRE'].$sql; $info = mcache_get($key); if(!$info){ $info = $GLOBALS['db']->getAll($sql); mcache_set($key,$info); }
把$sql md5?理吧。
memcache key有?度限制的。
$sql = "select id,avg_point,name,xpoint,ypoint,agent_area_id,area_id,supplier_id,index_img,dp_count,avg_point,deal_cate_id,ratio,area_id,note from aa where 1 = 1 and is_effect=1 and city_id in (18,1) order by id DESC limit 0,15";
$key = md5($GLOBALS['append_config']['IOS_CACHE_PRE'].$sql);
$info = mcache_get($key);
if(!$info){
$info = $GLOBALS['db']->getAll($sql);
mcache_set($key,$info);
}
是不是服务器数据就那么几条 不用分页啊? 导致每页数据都一样。。
数据有很多是需要分页的 Keys
----
Data stored by memcached is identified with the help of a key. A key
is a text string which should uniquely identify the data for clients
that are interested in storing and retrieving it. Currently the
length limit of a key is set at 250 characters (of course, normally
clients wouldn't need to use such long keys); the key must not include
control characters or whitespace.
百度翻译:
数据存储在memcached通过键值来标识。一个键的
是一个文本字符串必须唯一地识别客户的数据
有兴趣的存储和检索。目前,
一个键的 长度限制是250字符(当然,通常
客户不需要使用长键); 键必须不包括
控制字符或空格。
显然你已经违规了
ls已经说的很清楚了,虽然你的sql语句大约是220个字符长,并没有超出memcached的最大字符限制。但是因为sql中含有空格,所以,实际是使用sql的第一个空格之前的部分作为key的,这样的话,显然所有分页的数据都是一样的。
还是MD5搞起吧。
谢谢大家的热心回答

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...
