kredis 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kredis-1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 1.2
2
+ Name: kredis
3
+ Version: 1.0
4
+ Summary: kcwcache
5
+ Home-page: UNKNOWN
6
+ Author: 百里
7
+ Author-email: kwebs@kwebapp.cn
8
+ Maintainer: 坤坤
9
+ Maintainer-email: fk1402936534@qq.com
10
+ License: MIT License
11
+ Description: UNKNOWN
12
+ Keywords: kredis1.0
13
+ Platform: UNKNOWN
@@ -0,0 +1,4 @@
1
+ # -*- coding: utf-8 -*-
2
+ __version__ = '1.0'
3
+ from .redisclass import gtrdhersreegreshtrdhtrdhtr
4
+ redis=gtrdhersreegreshtrdhtrdhtr()
@@ -0,0 +1,716 @@
1
+ # -*- coding: utf-8 -*-
2
+ import json,copy,threading,time
3
+ def kcwredis_is_index(params,index):
4
+ try:
5
+ params[index]
6
+ except KeyError:
7
+ return False
8
+ except IndexError:
9
+ return False
10
+ else:
11
+ return True
12
+ try:
13
+ from kwebs.config import redis as tempredisconf
14
+ if not kcwredis_is_index(tempredisconf,'debug'):
15
+ tempredisconf['debug']=False
16
+ if not kcwredis_is_index(tempredisconf,'th_lock'):
17
+ tempredisconf['th_lock']=False
18
+ except:
19
+ tempredisconf={}
20
+ tempredisconf['debug']=False
21
+ tempredisconf['th_lock']=False
22
+ tempredisconf['host']='127.0.0.1' #服务器地址
23
+ tempredisconf['port']=6379 #端口
24
+ tempredisconf['password']='' #密码
25
+ tempredisconf['db']=0 #Redis数据库 注:Redis用0或1或2等表示
26
+ tempredisconf['pattern']=1 # 0短连接 1连接池
27
+ tempredisconf['ex']=0 #过期时间 (秒)
28
+ def kcwredis_print_log(*strs):
29
+ print(time.strftime("%Y-%m-%d %H:%M:%S"),*strs)
30
+ class gtrdhersreegreshtrdhtrdhtr:
31
+ "redis 注意:连接池链接模式下不支持动态配置"
32
+ __redisObj=None
33
+ __coninfo={}
34
+ __config=copy.deepcopy(tempredisconf)
35
+ __identifier=''
36
+ def __del__(self):
37
+ self.close(pattern=True,thlock=True,all=True)
38
+ def close(self,pattern=False,thlock=True,all=False):
39
+ try:
40
+ if self.__config['pattern']==1:
41
+ if all:
42
+ self.__redisObj=None
43
+ tarr=copy.copy(self.__coninfo)
44
+ for identifier in tarr:
45
+ if self.__coninfo[identifier]['obj']:
46
+ self.__coninfo[identifier]['obj'].close()
47
+ self.__coninfo[identifier]['redis_pool'].disconnect()
48
+ del self.__coninfo[identifier]
49
+ else:
50
+ if self.__redisObj:
51
+ self.__redisObj.close()
52
+ self.__redisObj=None
53
+ self.__coninfo[self.__identifier]['obj']=None
54
+ if pattern:
55
+ self.__coninfo[self.__identifier]['redis_pool'].disconnect()
56
+ del self.__coninfo[self.__identifier]
57
+ if self.__config['debug']:
58
+ kcwredis_print_log("redis连接池已关闭",self.__identifier)
59
+ elif self.__redisObj:
60
+ self.__redisObj.close()
61
+ self.__redisObj=None
62
+ except:
63
+ if thlock:
64
+ self.__close_th_lock()
65
+ raise
66
+ else:
67
+ if thlock:
68
+ self.__close_th_lock()
69
+ def __connects(self):
70
+ """设置redis链接"""
71
+ import redis as red
72
+ try:
73
+ if self.__config['pattern']==1:
74
+ self.__identifier=self.__config['host']+self.__config['password']+str(self.__config['port'])+str(self.__config['db'])
75
+ if self.__identifier not in self.__coninfo:
76
+ if self.__config['password']:
77
+ redis_pool=red.ConnectionPool(host=self.__config['host'],password=self.__config['password'],port=self.__config['port'],db=self.__config['db'])
78
+ else:
79
+ redis_pool=red.ConnectionPool(host=self.__config['host'],port=self.__config['port'],db=self.__config['db'])
80
+ if self.__config['debug']:
81
+ kcwredis_print_log("建立redis连接池",self.__identifier)
82
+ self.__coninfo[self.__identifier]={
83
+ 'obj':red.Redis(connection_pool=redis_pool),
84
+ 'redis_pool':redis_pool
85
+ }
86
+ else:
87
+ # kcwredis_print_log("self.__coninfo[self.__identifier]",self.__identifier,self.__coninfo)
88
+ self.__coninfo[self.__identifier]['obj']=red.Redis(connection_pool=self.__coninfo[self.__identifier]['redis_pool'])
89
+ self.__redisObj=self.__coninfo[self.__identifier]['obj']
90
+ else:
91
+ if self.__config['password']:
92
+ self.__redisObj=red.Redis(host=self.__config['host'],password=self.__config['password'],port=self.__config['port'],db=self.__config['db'])
93
+ else:
94
+ self.__redisObj=red.Redis(host=self.__config['host'],port=self.__config['port'],db=self.__config['db'])
95
+
96
+ if self.__config['debug']:
97
+ kcwredis_print_log("建立redis连接",self.__identifier)
98
+ except:
99
+ self.close()
100
+ raise
101
+
102
+ def __json_decode(self,strs):
103
+ """json字符串转python类型"""
104
+ try:
105
+ return json.loads(strs)
106
+ except Exception:
107
+ return {}
108
+ def __json_encode(self,strs):
109
+ """转成字符串"""
110
+ try:
111
+ return json.dumps(strs,ensure_ascii=False)
112
+ except Exception:
113
+ return ""
114
+ # def getconfig(self):
115
+ # return self.__config
116
+ __thlock={
117
+ 'obj':None,
118
+ 'status':False
119
+ }
120
+ def __start_th_lock(self):
121
+ """开启线程锁 多线程中建议开启 注意 这个python多线程锁 而不是数据库事务锁"""
122
+ if not self.__thlock['obj']:
123
+ self.__thlock['obj']=threading.Lock()
124
+ self.__thlock['obj'].acquire()
125
+ self.__thlock['status']=True
126
+ if self.__config['debug']:
127
+ kcwredis_print_log('开启线程锁redis')
128
+ def __close_th_lock(self):
129
+ """退出线程锁 这个python多线程锁 而不是数据库事务锁"""
130
+ if self.__thlock['status']:
131
+ self.__thlock['obj'].release()
132
+ self.__thlock['status']=False
133
+ if self.__config['debug']:
134
+ kcwredis_print_log('退出线程锁redis')
135
+ def connect(self,configs=None):
136
+ """设置redis链接信息
137
+
138
+ 参数 config 参考配置信息格式
139
+
140
+ 返回 redis
141
+ """
142
+ # if th_lock!='no':
143
+ # self.__config['th_lock']=th_lock
144
+ if self.__config['th_lock']:
145
+ self.__start_th_lock()
146
+ if configs:
147
+ self.__config=copy.deepcopy(tempredisconf)
148
+ if isinstance(configs,int):
149
+ self.__config['db']=configs
150
+ elif isinstance(configs,dict):
151
+ if "host" in configs:
152
+ self.__config['host']=configs['host']
153
+ if "port" in configs:
154
+ self.__config['port']=configs['port']
155
+ if "password" in configs:
156
+ self.__config['password']=configs['password']
157
+ if "db" in configs:
158
+ self.__config['db']=configs['db']
159
+ else:
160
+ raise Exception("配置信息错误")
161
+ else:
162
+ self.__config=copy.deepcopy(tempredisconf)
163
+ return self
164
+
165
+ def redisObj(self):
166
+ "得到一个redis连接对象,执行更多高级操作"
167
+ self.__connects()
168
+ return self.__redisObj
169
+ def incrby(self,name,value,ex=0):
170
+ """设置自增数量
171
+
172
+ name,键
173
+
174
+ value,值 自增 步长
175
+
176
+ ex,过期时间(秒)
177
+ """
178
+ i=0
179
+ while True:
180
+ self.__connects()
181
+ try:
182
+ status=self.__redisObj.incrby(name,value)
183
+ except Exception as e:
184
+ stre=str(e)
185
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
186
+ i+=1
187
+ self.close(pattern=True,thlock=False)
188
+ if i>3:
189
+ self.__close_th_lock()
190
+ raise Exception(e)
191
+ else:
192
+ print("__redisObj_e",e)
193
+ self.close()
194
+ raise Exception(e)
195
+ else:
196
+ if ex and status:
197
+ self.__redisObj.expire(name, ex)
198
+ self.close()
199
+ break
200
+ return status
201
+ def getstr(self,name):
202
+ """获取name的值
203
+
204
+ name,键
205
+ 返回键“name”处的值,如果该键不存在,则返回“none”
206
+ """
207
+ i=0
208
+ while True:
209
+ self.__connects()
210
+ try:
211
+ value=self.__redisObj.get(name)
212
+ except Exception as e:
213
+ stre=str(e)
214
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
215
+ i+=1
216
+ self.close(pattern=True,thlock=False)
217
+ if i>3:
218
+ self.__close_th_lock()
219
+ raise Exception(e)
220
+ else:
221
+ print("__redisObj_e",e)
222
+ self.close()
223
+ raise Exception(e)
224
+ else:
225
+ self.close()
226
+ break
227
+ return value
228
+
229
+ def setstr(self,name,value,ex=None, px=None, nx=False, xx=False):
230
+ """
231
+ name,键
232
+
233
+ value,值 只能是字符串
234
+
235
+ ex,过期时间(秒)
236
+
237
+ px,过期时间(毫秒)
238
+
239
+ nx,如果设置为True,则只有key不存在时,当前set操作才执行,同#setnx(key, value)
240
+
241
+ xx,如果设置为True,则只有key存在时,当前set操作才执行
242
+ """
243
+ if not ex and not px:
244
+ if self.__config['ex']:
245
+ ex=self.__config['ex']
246
+ i=0
247
+ while True:
248
+ self.__connects()
249
+ try:
250
+ status=self.__redisObj.set(name, value, ex=ex, px=px, nx=nx, xx=xx)
251
+ except Exception as e:
252
+ stre=str(e)
253
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
254
+ i+=1
255
+ self.close(pattern=True,thlock=False)
256
+ if i>3:
257
+ self.__close_th_lock()
258
+ raise Exception(e)
259
+ else:
260
+ print("__redisObj_e",e)
261
+ self.close()
262
+ raise Exception(e)
263
+ else:
264
+ self.close()
265
+ break
266
+ return status
267
+ def append(self,name,value):
268
+ """将字符串“value”追加到“name”处的值。如果``键`` 不存在,请使用值“name”创建它。 返回位于“name”的值的新长度。
269
+
270
+ name,键
271
+
272
+ value,值 只能是字符串
273
+ """
274
+ i=0
275
+ while True:
276
+ self.__connects()
277
+ try:
278
+ status=self.__redisObj.append(name,value)
279
+ except Exception as e:
280
+ stre=str(e)
281
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
282
+ i+=1
283
+ self.close(pattern=True,thlock=False)
284
+ if i>3:
285
+ self.__close_th_lock()
286
+ raise Exception(e)
287
+ else:
288
+ print("__redisObj_e",e)
289
+ self.close()
290
+ raise Exception(e)
291
+ else:
292
+ self.close()
293
+ break
294
+ return status
295
+ def set(self,name,value,ex=None, px=None, nx=False, xx=False):
296
+ """
297
+ name,键
298
+
299
+ value,值 可以是字典 列表 或字符串
300
+
301
+ ex,过期时间(秒)
302
+
303
+ px,过期时间(毫秒)
304
+
305
+ nx,如果设置为True,则只有key不存在时,当前set操作才执行
306
+
307
+ xx,如果设置为True,则只有key存在时,当前set操作才执行
308
+ """
309
+ if not ex and not px:
310
+ if self.__config['ex']:
311
+ ex=self.__config['ex']
312
+ value=self.__json_encode(value)
313
+ i=0
314
+ while True:
315
+ self.__connects()
316
+ try:
317
+ status=self.__redisObj.set(name, value, ex=ex, px=px, nx=nx, xx=xx)
318
+ except Exception as e:
319
+ stre=str(e)
320
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
321
+ i+=1
322
+ self.close(pattern=True,thlock=False)
323
+ if i>3:
324
+ self.__close_th_lock()
325
+ raise Exception(e)
326
+ else:
327
+ print("__redisObj_e",e)
328
+ self.close()
329
+ raise Exception(e)
330
+ else:
331
+ self.close()
332
+ break
333
+ return status
334
+ def get(self,name):
335
+ """获取name的值
336
+
337
+ name,键
338
+ 返回键“name”处的值,如果该键不存在,则返回“none”
339
+ """
340
+ i=0
341
+ while True:
342
+ self.__connects()
343
+ try:
344
+ value=self.__redisObj.get(name)
345
+ except Exception as e:
346
+ stre=str(e)
347
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
348
+ i+=1
349
+ self.close(pattern=True,thlock=False)
350
+ if i>3:
351
+ self.__close_th_lock()
352
+ raise Exception(e)
353
+ else:
354
+ print("__redisObj_e",e)
355
+ self.close()
356
+ raise Exception(e)
357
+ else:
358
+ self.close()
359
+ break
360
+ if value:
361
+ value=self.__json_decode(value)
362
+ return value
363
+ def delete(self,name):
364
+ """删除name的值
365
+
366
+ name,键
367
+
368
+ 返回 True,如果该键不存在,则返回 0
369
+ """
370
+ i=0
371
+ while True:
372
+ self.__connects()
373
+ try:
374
+ status=self.__redisObj.delete(name)
375
+ except Exception as e:
376
+ stre=str(e)
377
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
378
+ i+=1
379
+ self.close(pattern=True,thlock=False)
380
+ if i>3:
381
+ self.__close_th_lock()
382
+ raise Exception(e)
383
+ else:
384
+ print("__redisObj_e",e)
385
+ self.close()
386
+ raise Exception(e)
387
+ else:
388
+ self.close()
389
+ break
390
+ return status
391
+ def rpush(self,name, *values):
392
+ "元素从list的右边加入 ,可以添加多个"
393
+ i=0
394
+ while True:
395
+ self.__connects()
396
+ try:
397
+ status=self.__redisObj.rpush(name, *values)
398
+ except Exception as e:
399
+ stre=str(e)
400
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
401
+ i+=1
402
+ self.close(pattern=True,thlock=False)
403
+ if i>3:
404
+ self.__close_th_lock()
405
+ raise Exception(e)
406
+ else:
407
+ print("__redisObj_e",e)
408
+ self.close()
409
+ raise Exception(e)
410
+ else:
411
+ self.close()
412
+ break
413
+ return status
414
+ def rpop(self,name):
415
+ "元素从list的右边移出"
416
+ i=0
417
+ while True:
418
+ self.__connects()
419
+ try:
420
+ status=self.__redisObj.rpop(name)
421
+ except Exception as e:
422
+ stre=str(e)
423
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
424
+ i+=1
425
+ self.close(pattern=True,thlock=False)
426
+ if i>3:
427
+ self.__close_th_lock()
428
+ raise Exception(e)
429
+ else:
430
+ print("__redisObj_e",e)
431
+ self.close()
432
+ raise Exception(e)
433
+ else:
434
+ self.close()
435
+ break
436
+ return status
437
+ def rpoplpush(self,src, dst):
438
+ "元素从list的右边移出,并且从list的左边加入"
439
+ i=0
440
+ while True:
441
+ self.__connects()
442
+ try:
443
+ status=self.__redisObj.rpoplpush(src, dst)
444
+ except Exception as e:
445
+ stre=str(e)
446
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
447
+ i+=1
448
+ self.close(pattern=True,thlock=False)
449
+ if i>3:
450
+ self.__close_th_lock()
451
+ raise Exception(e)
452
+ else:
453
+ print("__redisObj_e",e)
454
+ self.close()
455
+ raise Exception(e)
456
+ else:
457
+ self.close()
458
+ break
459
+ return status
460
+ def rpushx(self,name, value):
461
+ "当name存在时,元素才能从list的右边加入"
462
+ i=0
463
+ while True:
464
+ self.__connects()
465
+ try:
466
+ status=self.__redisObj.rpushx(name, value)
467
+ except Exception as e:
468
+ stre=str(e)
469
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
470
+ i+=1
471
+ self.close(pattern=True,thlock=False)
472
+ if i>3:
473
+ self.__close_th_lock()
474
+ raise Exception(e)
475
+ else:
476
+ print("__redisObj_e",e)
477
+ self.close()
478
+ raise Exception(e)
479
+ else:
480
+ self.close()
481
+ break
482
+ return status
483
+ def lpush(self,name, *values):
484
+ "元素从list的左边加入,可以添加多个"
485
+ i=0
486
+ while True:
487
+ self.__connects()
488
+ try:
489
+ status=self.__redisObj.lpush(name, *values)
490
+ except Exception as e:
491
+ stre=str(e)
492
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
493
+ i+=1
494
+ self.close(pattern=True,thlock=False)
495
+ if i>3:
496
+ self.__close_th_lock()
497
+ raise Exception(e)
498
+ else:
499
+ print("__redisObj_e",e)
500
+ self.close()
501
+ raise Exception(e)
502
+ else:
503
+ self.close()
504
+ break
505
+ return status
506
+ def lpop(self,name):
507
+ "元素从list的左边移出"
508
+ i=0
509
+ while True:
510
+ self.__connects()
511
+ try:
512
+ status=self.__redisObj.lpop(name)
513
+ except Exception as e:
514
+ stre=str(e)
515
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
516
+ i+=1
517
+ self.close(pattern=True,thlock=False)
518
+ if i>3:
519
+ self.__close_th_lock()
520
+ raise Exception(e)
521
+ else:
522
+ print("__redisObj_e",e)
523
+ self.close()
524
+ raise Exception(e)
525
+ else:
526
+ self.close()
527
+ break
528
+ return status
529
+ def lpushxs(self,name):
530
+ "当name存在时,元素才能从list的左边加入"
531
+ i=0
532
+ while True:
533
+ self.__connects()
534
+ try:
535
+ status=self.__redisObj.lpushx(name)
536
+ except Exception as e:
537
+ stre=str(e)
538
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
539
+ i+=1
540
+ self.close(pattern=True,thlock=False)
541
+ if i>3:
542
+ self.__close_th_lock()
543
+ raise Exception(e)
544
+ else:
545
+ print("__redisObj_e",e)
546
+ self.close()
547
+ raise Exception(e)
548
+ else:
549
+ self.close()
550
+ break
551
+ return status
552
+ def hset(self,name,key,value):
553
+ """在hash名称中将key设置为value如果HSET创建了新字段,则返回1,否则返回0
554
+
555
+ name,名
556
+
557
+ key,键
558
+
559
+ mapping,值
560
+ """
561
+ i=0
562
+ while True:
563
+ self.__connects()
564
+ try:
565
+ status=self.__redisObj.hset(name,key,value)
566
+ except Exception as e:
567
+ stre=str(e)
568
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
569
+ i+=1
570
+ self.close(pattern=True,thlock=False)
571
+ if i>3:
572
+ self.__close_th_lock()
573
+ raise Exception(e)
574
+ else:
575
+ print("__redisObj_e",e)
576
+ self.close()
577
+ raise Exception(e)
578
+ else:
579
+ self.close()
580
+ break
581
+ return status
582
+
583
+ def hget(self,name,key):
584
+ "返回hash的name中的key值"
585
+ i=0
586
+ while True:
587
+ self.__connects()
588
+ try:
589
+ status=self.__redisObj.hget(name,key)
590
+ except Exception as e:
591
+ stre=str(e)
592
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
593
+ i+=1
594
+ self.close(pattern=True,thlock=False)
595
+ if i>3:
596
+ self.__close_th_lock()
597
+ raise Exception(e)
598
+ else:
599
+ print("__redisObj_e",e)
600
+ self.close()
601
+ raise Exception(e)
602
+ else:
603
+ self.close()
604
+ break
605
+ return status
606
+ def hgetall(self,name):
607
+ "返回hash名称/值对的Python dict"
608
+ i=0
609
+ while True:
610
+ self.__connects()
611
+ try:
612
+ data=self.__redisObj.hgetall(name)
613
+ except Exception as e:
614
+ stre=str(e)
615
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
616
+ i+=1
617
+ self.close(pattern=True,thlock=False)
618
+ if i>3:
619
+ self.__close_th_lock()
620
+ raise Exception(e)
621
+ else:
622
+ print("__redisObj_e",e)
623
+ self.close()
624
+ raise Exception(e)
625
+ else:
626
+ self.close()
627
+ break
628
+ return data
629
+
630
+ def hdel(self,name,key):
631
+ """在hash名称中将key删除
632
+
633
+ name,名
634
+
635
+ key,键
636
+ """
637
+ i=0
638
+ while True:
639
+ self.__connects()
640
+ try:
641
+ status=self.__redisObj.hdel(name,key)
642
+ except Exception as e:
643
+ stre=str(e)
644
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
645
+ i+=1
646
+ self.close(pattern=True,thlock=False)
647
+ if i>3:
648
+ self.__close_th_lock()
649
+ raise Exception(e)
650
+ else:
651
+ print("__redisObj_e",e)
652
+ self.close()
653
+ raise Exception(e)
654
+ else:
655
+ self.close()
656
+ break
657
+ return status
658
+ def hmset(self,name,mapping,ex=0):
659
+ """在hash的name中为每个键设置值
660
+ name,键
661
+
662
+ mapping,值
663
+
664
+ ex,过期时间(秒)
665
+
666
+ """
667
+ i=0
668
+ while True:
669
+ self.__connects()
670
+ try:
671
+ status=self.__redisObj.hmget(name, keys, *args)
672
+ except Exception as e:
673
+ stre=str(e)
674
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
675
+ i+=1
676
+ self.close(pattern=True,thlock=False)
677
+ if i>3:
678
+ self.__close_th_lock()
679
+ raise Exception(e)
680
+ else:
681
+ print("__redisObj_e",e)
682
+ self.close()
683
+ raise Exception(e)
684
+ else:
685
+ if not ex:
686
+ if self.__config['ex']:
687
+ ex=self.__config['ex']
688
+ if ex:
689
+ self.__redisObj.expire(name,ex)
690
+ self.close()
691
+ break
692
+ return status
693
+ def hmget(self,name, keys, *args):
694
+ "返回与“keys”顺序相同的值列表``"
695
+ i=0
696
+ while True:
697
+ self.__connects()
698
+ try:
699
+ status=self.__redisObj.hmget(name, keys, *args)
700
+ except Exception as e:
701
+ stre=str(e)
702
+ if 'Error while reading from socket' in stre or 'Error 10054 while writing to socket' in stre or 'Connection timed out' in stre:
703
+ i+=1
704
+ self.close(pattern=True,thlock=False)
705
+ if i>3:
706
+ self.__close_th_lock()
707
+ raise Exception(e)
708
+ else:
709
+ print("__redisObj_e",e)
710
+ self.close()
711
+ raise Exception(e)
712
+ else:
713
+ self.close()
714
+ break
715
+ return status
716
+
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 1.2
2
+ Name: kredis
3
+ Version: 1.0
4
+ Summary: kcwcache
5
+ Home-page: UNKNOWN
6
+ Author: 百里
7
+ Author-email: kwebs@kwebapp.cn
8
+ Maintainer: 坤坤
9
+ Maintainer-email: fk1402936534@qq.com
10
+ License: MIT License
11
+ Description: UNKNOWN
12
+ Keywords: kredis1.0
13
+ Platform: UNKNOWN
@@ -0,0 +1,8 @@
1
+ setup.py
2
+ kredis/__init__.py
3
+ kredis/redisclass.py
4
+ kredis.egg-info/PKG-INFO
5
+ kredis.egg-info/SOURCES.txt
6
+ kredis.egg-info/dependency_links.txt
7
+ kredis.egg-info/requires.txt
8
+ kredis.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ redis==3.3.8
@@ -0,0 +1 @@
1
+ kredis
kredis-1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
kredis-1.0/setup.py ADDED
@@ -0,0 +1,52 @@
1
+
2
+ # 打包上传 python setup.py sdist upload
3
+ # 安装 python setup.py install
4
+ import os,sys
5
+ from kredis import __version__
6
+ from setuptools import setup
7
+ confkcws={}
8
+ confkcws['name']='kredis'
9
+ confkcws['version']=__version__
10
+ confkcws['description']='kcwcache'
11
+ confkcws['long_description']=''
12
+ confkcws['license']='MIT License'
13
+ confkcws['url']=''
14
+ confkcws['author']='百里'
15
+ confkcws['author_email']='kwebs@kwebapp.cn'
16
+ confkcws['maintainer']='坤坤'
17
+ confkcws['maintainer_email']='fk1402936534@qq.com'
18
+ def get_file(folder='./',lists=[]):
19
+ lis=os.listdir(folder)
20
+ for files in lis:
21
+ if not os.path.isfile(folder+"/"+files):
22
+ if files=='__pycache__' or files=='.git':
23
+ pass
24
+ else:
25
+ lists.append(folder+"/"+files)
26
+ get_file(folder+"/"+files,lists)
27
+ else:
28
+ pass
29
+ return lists
30
+ def start():
31
+ b=get_file("kredis",['kredis'])
32
+ setup(
33
+ name = confkcws["name"],
34
+ version = confkcws["version"],
35
+ keywords = "kredis"+confkcws['version'],
36
+ description = confkcws["description"],
37
+ long_description = confkcws["long_description"],
38
+ license = confkcws["license"],
39
+ author = confkcws["author"],
40
+ author_email = confkcws["author_email"],
41
+ maintainer = confkcws["maintainer"],
42
+ maintainer_email = confkcws["maintainer_email"],
43
+ url=confkcws['url'],
44
+ packages = b,
45
+
46
+
47
+ install_requires = ['redis==3.3.8'], #第三方包
48
+ package_data = {
49
+ '': ['*.html', '*.js','*.css','*.jpg','*.png','*.gif'],
50
+ }
51
+ )
52
+ start()