kk-koa-framework
Advanced tools
Comparing version 3.1.5 to 3.1.6
@@ -6,3 +6,3 @@ { | ||
"name": "kk-koa-framework", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"description": "kk koa mvc webframework", | ||
@@ -9,0 +9,0 @@ "main": "index.js", |
# kk-koa-framework | ||
## 3.1.6 版本改动 | ||
增加Redis hget方法 | ||
## 3.1.1 版本改动 | ||
@@ -5,0 +8,0 @@ |
@@ -12,2 +12,3 @@ | ||
const setCache = async (sid,obj,ttl) => store.set(obj,{sid,ttl}) | ||
const hgetCache = async (key_name, field_name) => store.hget(key_name, field_name) | ||
const deleteCache = async (sid)=>store.destroy(sid) | ||
@@ -25,2 +26,3 @@ | ||
ctx.cache.get = getCache | ||
ctx.cache.hget = hgetCache | ||
ctx.cache.set = setCache | ||
@@ -27,0 +29,0 @@ ctx.cache.destroy = deleteCache |
@@ -89,2 +89,9 @@ const Redis = require('ioredis') | ||
async hget(key, subKey) { | ||
key = this.prefix && key.indexOf('_') !== 0 ? `${this.prefix}:${key}` : key | ||
let data = await this.redis.hget([key, subKey]) | ||
data && this.ttl && this.redis.expire(key, this.ttl) | ||
return JSON.parse(data) | ||
} | ||
async set(obj, { | ||
@@ -91,0 +98,0 @@ sid = this.getID(24), |
124004
1438
399