pull/522/head
Mr Chen 1 year ago
parent dc8f508ac5
commit 65e87fec1a
  1. 44
      plugins/data_query/nosql_memcached.py
  2. 4
      plugins/data_query/static/html/index.html
  3. 75
      plugins/data_query/static/js/app.js

@ -108,6 +108,10 @@ class nosqlMemcachedCtr():
v_str = v.decode()
if not v_str in item_no:
item_no.append(v_str)
if len(item_no) == 0:
item_no = [0]
result['items'] = item_no
return mw.returnData(True,'ok', result)
@ -127,6 +131,9 @@ class nosqlMemcachedCtr():
size = args['size']
item_id = args['item_id']
if item_id == '0':
return mw.returnData(False,'ok')
m_items = mem_instance.stats('items')
item_key = 'items:%s:number' % item_id
@ -143,13 +150,19 @@ class nosqlMemcachedCtr():
all_key = mem_instance.stats('cachedump', str(item_id) , str(0))
# print(all_key)
all_key_list = []
cur_time_t = time.time()
for k in all_key:
t = {}
t['k'] = k.decode("utf-8")
v = all_key[k].decode("utf-8")
v = v.strip('[').strip(']').split(';')
t['s'] = v[0]
t['t'] = v[1].strip().split(' ')[0]
cur_time = v[1].strip().split(' ')[0]
if int(cur_time) != 0 :
t['t'] = int(cur_time) - int(cur_time_t)
else:
t['t'] = 0
all_key_list.append(t)
# print(len(all_key_list))
@ -184,6 +197,27 @@ class nosqlMemcachedCtr():
mem_instance.delete(key)
return mw.returnData(True,'删除成功!')
def setKv(self, args):
sid = args['sid']
mem_instance = self.getInstanceBySid(sid).conn()
if mem_instance is False:
return mw.returnData(False,'无法链接')
key = args['key']
val = args['val']
endtime = args['endtime']
mem_instance.set(key, val, int(endtime))
return mw.returnData(True,'设置成功!')
def clear(self, args):
sid = args['sid']
mem_instance = self.getInstanceBySid(sid).conn()
if mem_instance is False:
return mw.returnData(False,'无法链接')
mem_instance.flush_all()
return mw.returnData(True,'清空成功!')
# ---------------------------------- run ----------------------------------
# 获取 memcached 列表
@ -199,6 +233,14 @@ def del_val(args):
t = nosqlMemcachedCtr()
return t.delVal(args)
def set_kv(args):
t = nosqlMemcachedCtr()
return t.setKv(args)
def clear(args):
t = nosqlMemcachedCtr()
return t.clear(args)
# 测试
def test(args):
sid = args['sid']

@ -69,7 +69,7 @@
</div>
<!-- mongodb end -->
<!-- reids start -->
<!-- redis start -->
<div class="tab-con show w-full" id="redis" style="padding: 0px;">
<div id="redis_ctr" style="position: relative;">
<div class="tootls_group tootls_top">
@ -129,7 +129,7 @@
</div>
</div>
</div>
<!-- reids end -->
<!-- redis end -->
<!-- memcached start -->
<div class="tab-con hide" id="memcached" style="padding: 0px;">

@ -173,6 +173,22 @@ function initTabMongodb(){
function initTabMemcached(){
memcachedGetList();
$('#memcached_add_key').unbind('click').click(function(){
memcachedAdd();
});
$('#memcached_clear_all').unbind('click').click(function(){
var sid = memcachedGetSid();
memPostCB('clear',{'sid':sid} ,function(rdata){
console.log(rdata);
showMsg(rdata.data.msg,function(){
if (rdata.data.status){
memcachedGetList();
}
},{icon: rdata.data.status ? 1 : 2}, 2000);
});
});
}
// ------------------------- memcached start -------------------------------
@ -203,12 +219,11 @@ function memcachedGetList(){
$('#memcached .item_list select').change(function(){
memcachedGetKeyList(1);
});
memcachedGetKeyList(1);
closeInstallLayer();
} else {
showInstallLayer();
}
memcachedGetKeyList(1);
});
}
@ -256,6 +271,8 @@ function memcachedGetKeyList(p){
var i = $(this).data('index');
copyText(dlist[i]['v']);
});
} else {
$('.memcached_table_content tbody').html('');
}
});
}
@ -275,6 +292,60 @@ function memcachedDeleteKey(key){
});
}
function memcachedAdd(){
layer.open({
type: 1,
area: '480px',
title: '添加Key至服务器',
closeBtn: 1,
shift: 0,
shadeClose: false,
btn:['确定','取消'],
content: "<form class='bt-form pd20'>\
<div class='line'>\
<span class='tname'></span>\
<div class='info-r c4'>\
<input class='bt-input-text' type='text' name='key' placeholder='键' style='width:260px;'/>\
</div>\
</div>\
<div class='line'>\
<span class='tname'></span>\
<div class='info-r c4'>\
<textarea class='bt-input-text' name='val' style='width:260px;height:100px;'/></textarea>\
</div>\
</div>\
<div class='line'>\
<span class='tname'>有效期</span>\
<div class='info-r c4'>\
<input class='bt-input-text mr5' type='number' name='endtime' value='60' style='width:260px;'/>\
</div>\
</div>\
<div class='line'>\
<div>\
<ul class='help-info-text c7' style='margin-left:30px;'><li>有效期为0表示永久</li>\
</div>\
</div>\
</form>",
success:function(){
},
yes: function(index){
var data = {};
data['sid'] = memcachedGetSid();
data['key'] = $('input[name="key"]').val();
data['val'] = $('textarea[name="val"]').val();
data['endtime'] = $('input[name="endtime"]').val();
memPostCB('set_kv', data ,function(rdata){
showMsg(rdata.data.msg,function(){
layer.close(index);
memcachedGetList();
},{icon: rdata.data.status ? 1 : 2}, 1000);
});
}
});
}
// ------------------------- memcached end ---------------------------------
// ------------------------- mongodb start ---------------------------------

Loading…
Cancel
Save