Commit Graph

10 Commits

Author SHA1 Message Date
cnzgray e5aa28a79b fix: can not get cache (#1143)
本补丁主要解决了以下两个问题:

1. 在 a1f060f3d2 提交时,缓存get方法发生了变化。
**cache的get方法未正确返回值**,这将导致所有使用自定义缓存的地方缓存丢失!

2. 同时修正了未设置缓存时系统报`tryGet`方法未定义的问题。
2018-11-14 12:14:43 +08:00
cnzgray d1c50b0c7e 提案: 添加一个`tryGet`方法到cache工具中。 (#1130)
在抓取一些博客或者论坛的时候,有时候会系统抓取内容页面作为desc。
大多数的做法是获取子页面的地址,然后判断是否已经缓存结果,如果没有则获取,然后设置到缓存中。
这做法固然没有问题,这里只是提供一种新的思路,以将子页面的抓取逻辑独立出去便于逻辑实现。

使用方法:
```
const loadContent = async (link) => {
    // 执行页面加载,解析内容等操作。
    // 最终返回一个结果,该结果将被缓存。
    return result;
}
const result = await ctx.cache.tryGet(link, async () => loadContent(link), 3 * 60 * 60);
```
2018-11-13 10:57:13 +08:00
DIYgod a1f060f3d2
verify cache value 2018-11-03 11:25:39 +08:00
DIYgod d92170bdd7
format 2018-10-19 01:06:08 +08:00
Henry Wang 465324b67d 精简缓存逻辑,精简文档 (#915)
https://github.com/HenryQW/RSSHub/issues/6
https://github.com/HenryQW/RSSHub/issues/7
2018-10-18 09:44:45 +08:00
DIYgod a48a276485
app: exclude cache for root router 2018-09-30 17:02:18 +08:00
DIYgod 108f4bf0ce
app: remove empty password 2018-05-18 14:59:04 +08:00
DIYgod c893d1ad17
app: expose cache function to koa context 2018-05-18 01:31:51 +08:00
さくら 49de384d2e feat: add prettier and commit hooks (#144)
* feat: add prettier and commit hooks

* style(*): prettier format

* fix(eslint): parsing error: Unexpected token ...

* style(eslint): eslint --fix

* style(bilibili): fix `no-undef` and `no-unused-vars`

* style(jiandan): fix eqeqeq

* style(pixiv): disable `no-constant-condition` rule for eslint

* fix(pixiv): use template string

* style(toutiao): remove unused variables

* style(weibo): use `forEach` instead of `map`

The array has no return value, you should use `forEach` instead of `map`

* chore(hooks): add eslint hooks

* chore(hooks): switch from husky to yorkie

* style(zhihu): prettier format

* style(docs): fix vuepress custom container

https://vuepress.vuejs.org/guide/markdown.html#custom-containers

* chore(prettier): set a more reasonable `printWidth` value

* style(*): better prettier format
2018-05-17 10:52:29 +08:00
DIYgod 16c32f7824
app: fix redis cache 2018-05-16 01:17:06 +08:00