def zsetRange(): """ show the list of item from zst :return: """ set_name = request.args.get('name') start = request.args.get('start', "") page_num = request.args.get('page_num', 1) page_size = request.args.get('page_size') if not page_size: page_size = request.cookies.get('SIZE', 10) db_object = SSDBClient(request) item_total = db_object.zsetSize(set_name) page_count, page_num = getPagingTabsInfo(item_total, page_num, page_size) offset = (page_num - 1) * int(page_size) if start: rank = db_object.zsetRank(set_name, start) if rank: page_num = getPageNumberInfo(rank, page_count, page_size) offset = (page_num - 1) * int(page_size) item_list = db_object.zsetRange(set_name, offset=offset, limit=page_size) select_arg = {'page_size': int(page_size)} resp = make_response( render_template('zset/zset_range.html', item_list=item_list, name=set_name, page_num=int(page_num), page_count=page_count, select_arg=select_arg, start=start, active='zset')) resp.set_cookie('SIZE', str(page_size), httponly=True, samesite='Lax') return resp
def hashScan(): """ show the list of hash item :return: """ name = request.args.get('name') key_start = request.args.get('start', '') page_size = request.args.get('page_size') page_number = int(request.args.get('page_num', 1)) if not page_size: page_size = request.cookies.get('SIZE', 10) db_client = SSDBClient(request) limit = int(page_size) * page_number item_list = db_client.hashScan(name, key_start, "", limit=limit + 1) if len(item_list) > limit: has_next = True item_list = item_list[-int(page_size) - 1:-1] else: has_next = False item_list = item_list[-int(page_size):] select_arg = {'page_size': int(page_size), 'start': key_start} resp = make_response( render_template('hash/hash_scan.html', item_list=item_list, page_num=page_number, key_start=key_start, name=name, has_next=has_next, has_prev=page_number > 1, select_arg=select_arg, active='hash')) resp.set_cookie('SIZE', str(page_size), httponly=True, samesite='Lax') return resp
def zsetLists(): """ show the items of zset :return: """ page_num = int(request.args.get('page_num', 1)) page_size = request.args.get('page_size') if not page_size: page_size = request.cookies.get('SIZE', 20) start = request.args.get('start', '') db_client = SSDBClient(request) zset_list, has_next = db_client.zsetList(start=start, page_num=page_num, page_size=int(page_size)) select_arg = {'start': start, 'page_size': int(page_size)} resp = make_response( render_template('zset/zset.html', zset_list=zset_list, has_next=has_next, has_prev=page_num > 1, page_num=page_num, select_arg=select_arg, active='zset')) resp.set_cookie('SIZE', str(page_size), secure=True, httponly=True, samesite='Lax') return resp
def kvScan(): """ show the list of kv item """ key_start = request.args.get('start', '') page_size = request.args.get('page_size') page_number = int(request.args.get('page_num', 1)) if not page_size: page_size = request.cookies.get('SIZE', 10) db_client = SSDBClient(request) limit = int(page_size) * page_number item_list = db_client.kvScan(key_start, "", limit=limit + 1) if len(item_list) > limit: has_next = True item_list = item_list[-int(page_size) - 1:-1] else: has_next = False item_list = item_list[-int(page_size):] select_arg = {'page_size': int(page_size), 'start': key_start} resp = make_response( render_template('kv/kv_scan.html', item_list=item_list, page_num=page_number, key_start=key_start, has_next=has_next, has_prev=page_number > 1, select_arg=select_arg, active='kv')) resp.set_cookie('SIZE', str(page_size)) return resp
def queueLists(): """ show the items of queue/list :return: """ page_num = int(request.args.get('page_num', 1)) page_size = request.args.get('page_size') if not page_size: page_size = request.cookies.get('SIZE', 10) start = request.args.get('start', '') end = request.args.get('end', '') db_client = SSDBClient(request) queue_list, has_next = db_client.queueList(name_start=start, name_end=end, page_num=page_num, page_size=int(page_size)) select_arg = {'start': start, 'end': end, 'page_size': int(page_size)} resp = make_response( render_template('queue/queue.html', queue_list=queue_list, has_next=has_next, has_prev=page_num > 1, page_num=page_num, select_arg=select_arg, active='queue')) resp.set_cookie("SIZE", str(page_size)) return resp
def hashLists(): """ show the list of hash :return: """ page_num = int(request.args.get('page_num', 1)) page_size = request.args.get('page_size') if not page_size: page_size = request.cookies.get('SIZE', 10) start = request.args.get('start', '') end = request.args.get('end', '') db_client = SSDBClient(request) hash_list, has_next = db_client.hashList(name_start=start, name_end=end, page_num=page_num, page_size=int(page_size)) select_arg = {'start': start, 'end': end, 'page_size': int(page_size)} resp = make_response( render_template('hash/hash.html', hash_list=hash_list, has_next=has_next, has_prev=page_num > 1, page_num=page_num, select_arg=select_arg, active='hash')) resp.set_cookie("SIZE", str(page_size), httponly=True, samesite='Lax') return resp
def queueGet(): """ show an item info from queue :return: """ queue_name = request.args.get('name') index = request.args.get('index') item = SSDBClient(request).queueGet(queue_name, index) return render_template('queue/queueGet.html', name=queue_name, item=item, index=index, active='queue')
def index(): host, port = getSAServer(request) server_info = SSDBClient(request).serverInfo() resp = make_response(render_template('index.html', server_info=server_info)) resp.set_cookie('SSDBADMINSERVER', '{host}:{port}'.format(host=host, port=port), httponly=True, samesite='Lax') return resp
def index(): host, port, password = getSAServer(request) server_info = SSDBClient(request).serverInfo() resp = make_response(render_template('index.html', server_info=server_info)) resp.set_cookie( 'SSDBADMINSERVER', '{host}:{port}:{password}'.format(host=host, port=port, password=password)) return resp
def queueClear(): """ delete the specified queue :return: """ if request.method == 'POST': queue_name = request.form.get('name') SSDBClient(request).queueClear(queue_name) return redirect(url_for('queueLists')) else: queue_name = request.args.get('name') return render_template('queue/queue_clear.html', name=queue_name, active='queue')
def kvGet(): """ show a kv info """ key = request.args.get('key') value, ttl = SSDBClient(request).kvGet(key) return render_template('kv/kv_get.html', key=key, value=value, ttl=ttl, active='kv') pass
def hashGet(): """ show an item info from hash :return: """ name = request.args.get('name') key = request.args.get('key') value = SSDBClient(request).hashGet(name, key) return render_template('hash/hash_get.html', name=name, value=value, key=key, active='hash')
def queueRange(): """ show the list of item from queue :return: """ queue_name = request.args.get('name') start = request.args.get('start') page_num = request.args.get('page_num', 1) page_size = request.args.get('page_size') if not page_size: page_size = request.cookies.get('SIZE', "10") db_object = SSDBClient(request) item_total = db_object.queueSize(queue_name) page_count, page_num = getPagingTabsInfo(item_total, page_num, page_size) offset = (page_num - 1) * int(page_size) if start and start.isdigit(): page_num = getPageNumberInfo(int(start), page_count, page_size) offset = (page_num - 1) * int(page_size) else: start = offset item_list = db_object.queueRange(queue_name, offset=offset, limit=page_size) select_arg = {'page_size': int(page_size)} resp = make_response( render_template('queue/queue_range.html', item_list=item_list, name=queue_name, page_num=int(page_num), page_count=page_count, select_arg=select_arg, start_index=offset, start=start, data_total=item_total, active='queue')) resp.set_cookie('SIZE', page_size, httponly=True, samesite='Lax') return resp
def zset_zget(): """ show item info from zset :return: """ name = request.args.get('name') key = request.args.get('key') score = SSDBClient(request).zsetGet(name, key) return render_template('zset/zset_get.html', name=name, score=score, key=key, active='zset')
def queuePop(): """ pop item(s) from queue (support back/front type) :return: """ if request.method == 'GET': queue_name = request.args.get('name') return render_template('queue/queue_pop.html', queue_name=queue_name, active='queue') else: queue_name = request.form.get('name') pop_type = request.form.get('type') number = request.form.get('number') SSDBClient(request).queuePop(queue_name, number, pop_type) return redirect(url_for('queueRange', name=queue_name))
def zsetClear(): """ delete the specified zset data :return: """ if request.method == 'POST': name = request.form.get('name') SSDBClient(request).zsetClear(name) return redirect(url_for('zsetLists')) else: queue_name = request.args.get('name') return render_template('zset/zset_clear.html', name=queue_name, active='zset')
def queuePush(): """ add item to queue(support back/front type) Returns: """ if request.method == 'GET': queue_name = request.args.get('name') return render_template('queue/queue_push.html', queue_name=queue_name, active='queue') elif request.method == "POST": queue_name = request.form.get('queue_name') push_type = request.form.get('type') item = request.form.get('item') SSDBClient(request).queuePush(queue_name, item, push_type) return redirect(url_for('queueRange', name=queue_name))
def kvDel(): """ remove keys from kv :return: """ if request.method == 'GET': key = request.args.get('key') keys = request.args.getlist('keys') if key: keys.append(key) return render_template('kv/kv_del.html', keys=keys, active='kv') else: keys = request.form.getlist('key') SSDBClient(request).kvDel(*keys) return redirect(url_for('kvScan'))
def hashClear(): """ delete the specified hash data :return: """ if request.method == 'POST': name = request.form.get('name') SSDBClient(request).hashClear(name) return redirect(url_for('hashLists')) else: name = request.args.get('name') return render_template('hash/hash_clear.html', name=name, active='hash') pass
def kvSet(): """ add item to kv """ if request.method == 'GET': key = request.args.get('key', '') value = request.args.get('value', '') return render_template('kv/kv_set.html', key=key, value=value, active='kv') else: key = request.form.get('key') value = request.form.get('value') SSDBClient(request).kvSet(key, value) return redirect(url_for('kvScan'))
def hashDel(): """ remove keys from zset_name :return: """ if request.method == 'GET': name = request.args.get('name') key = request.args.get('key') keys = request.args.getlist('keys') if key: keys.append(key) return render_template('hash/hash_del.html', keys=keys, name=name, active='hash') else: keys = request.form.getlist('key') name = request.form.get('name') SSDBClient(request).hashDel(name, *keys) return redirect(url_for('hashScan', name=name))
def hashSet(): """ Set the value of key within the hash_name :return: """ if request.method == 'GET': name = request.args.get('name') key = request.args.get('key', '') value = request.args.get('value', '') return render_template('hash/hash_set.html', name=name, key=key, value=value, active='hash') else: name = request.form.get('name') key = request.form.get('key') value = request.form.get('value') SSDBClient(request).hashSet(name, key, value) return redirect(url_for('hashScan', name=name)) pass
def zsetSet(): """ add item to zset :return: """ if request.method == 'GET': name = request.args.get('name') key = request.args.get('key', '') score = request.args.get('score', '') return render_template('zset/zset_set.html', name=name, key=key, score=score, active='zset') else: name = request.form.get('name') key = request.form.get('key') score = request.form.get('score') try: score = int(score) except ValueError: score = 0 SSDBClient(request).zsetSet(name, key, score) return redirect(url_for('zsetRange', name=name))