我使用python redis来匹配一些使用匹配选项的信息?但它不起作用.
import redis
import REDIS
class UserCache(object):
def __init__(self):
self.rds = self._connectRds()
def _connectRds(self):
_db = REDIS['usercache']
pool = redis.ConnectionPool(host=_db['HOST'], port= _db['PORT'], db=_db['DB'])
rds = redis.Redis(connection_pool=pool)
return rds
cache = UserCahce()
cache.rds.execute("scan", "0", match="userinfo_*")
Run Code Online (Sandbox Code Playgroud)
似乎匹配选项在scan命令中起作用.
在[68]:cache.rds.execute_command( "扫描", "0",匹配= "userinfo_*")停止[68]:[ '28',[ 'user_dev_20199116', 'devinfo_af85d776fcc9dbc56e3cca16594e1c9ec36fecd10000000001', 'devinfo_dd552211d1b97a825c416aaaf3c62ce8ce4661820000000002',' user_dev_2' , 'userinfo_20130243', 'session_r4XXdvzJ28VuPMoWWU4cnsNv7NEAAAAAAQ ==', 'devinfo_35372afae1de3dbf6a213f659c2814c7b1767f2400013436cc', 'session_3IaTKySREBKjMTAi1puQSwzO20wAAAAAAQ ==', 'session_3VUiEdG5eoJcQWqq88Ys6M5GYYIAAAAAAg ==', 'user_dev_20130243']]
我怀疑,这是我的表:
mysql> show create table watchdog\G
*************************** 1. row ***************************
Table: watchdog
Create Table: CREATE TABLE `watchdog` (
`index1` int(11) NOT NULL DEFAULT '0',
`index2` int(11) NOT NULL DEFAULT '0',
`dog` int(11) NOT NULL DEFAULT '9',
PRIMARY KEY (`index1`,`index2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
<1>首先查询:
select index1, index2
from watchdog
where index1 > 4000008 and index1 < 4200007;
Run Code Online (Sandbox Code Playgroud)
结果:
... | 4200001 | 4200002 | | 4200002 | 4200003 | | 4200003 | 4200004 | …