q-koa 9.7.4 → 9.8.0

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.
package/core/app.js CHANGED
@@ -873,7 +873,11 @@ class APP {
873
873
 
874
874
  if (fn === 'updateSort') {
875
875
  if (cacheModel.includes(controller)) {
876
- ctx.app[appName].cache.set(`${controller}`, null)
876
+ if (ctx.app[appName].redisClient) {
877
+ ctx.app[appName].redisClient.publish('cache clear', `${controller}`)
878
+ } else {
879
+ ctx.app[appName].cache.set(`${controller}`, null)
880
+ }
877
881
  }
878
882
  }
879
883
 
@@ -1759,6 +1763,16 @@ class APP {
1759
1763
  const result = await app[appName].model[controller][fn](list)
1760
1764
  ctx.SUCCESS(result)
1761
1765
  }
1766
+ if (cacheModel.includes(controller)) {
1767
+ if (ctx.app[appName].redisClient) {
1768
+ ctx.app[appName].redisClient.publish(
1769
+ 'cache clear',
1770
+ `${controller}`
1771
+ )
1772
+ } else {
1773
+ ctx.app[appName].cache.set(`${controller}`, null)
1774
+ }
1775
+ }
1762
1776
  }
1763
1777
 
1764
1778
  if (fn === 'upsert' || fn === 'create') {
@@ -1788,7 +1802,14 @@ class APP {
1788
1802
  ctx.SUCCESS(flag)
1789
1803
 
1790
1804
  if (cacheModel.includes(controller)) {
1791
- ctx.app[appName].cache.set(`${controller}`, null)
1805
+ if (ctx.app[appName].redisClient) {
1806
+ ctx.app[appName].redisClient.publish(
1807
+ 'cache clear',
1808
+ `${controller}`
1809
+ )
1810
+ } else {
1811
+ ctx.app[appName].cache.set(`${controller}`, null)
1812
+ }
1792
1813
  }
1793
1814
  }
1794
1815
 
@@ -1813,7 +1834,14 @@ class APP {
1813
1834
  ctx.SUCCESS(result)
1814
1835
 
1815
1836
  if (cacheModel.includes(controller)) {
1816
- ctx.app[appName].cache.set(`${controller}`, null)
1837
+ if (ctx.app[appName].redisClient) {
1838
+ ctx.app[appName].redisClient.publish(
1839
+ 'cache clear',
1840
+ `${controller}`
1841
+ )
1842
+ } else {
1843
+ ctx.app[appName].cache.set(`${controller}`, null)
1844
+ }
1817
1845
  }
1818
1846
  }
1819
1847
 
@@ -1964,11 +1992,11 @@ APP.getConfig = (app) => ({
1964
1992
  if (!result) throw new Error('没有这个type')
1965
1993
  return result
1966
1994
  },
1967
- update() {
1995
+ update(target = 'configList') {
1968
1996
  if (app.redisClient) {
1969
- app.redisClient.publish('cache clear', 'configList')
1997
+ app.redisClient.publish('cache clear', target)
1970
1998
  } else {
1971
- app.cache.set('configList', null)
1999
+ app.cache.set(target, null)
1972
2000
  }
1973
2001
  },
1974
2002
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "9.7.4",
3
+ "version": "9.8.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,14 +0,0 @@
1
- const { getAppByCtx, getConfig } = require('q-koa')
2
-
3
- exports.upsert = async (ctx) => {
4
- const { app } = getAppByCtx(ctx)
5
- const appConfig = getConfig(app)
6
- appConfig.update()
7
- }
8
-
9
- exports.bulkUpdate = async (ctx) => {
10
- const { app } = getAppByCtx(ctx)
11
-
12
- const appConfig = getConfig(app)
13
- appConfig.update()
14
- }