Skip to content

Commit

Permalink
✨ Add store extend
Browse files Browse the repository at this point in the history
  • Loading branch information
zswang committed Sep 12, 2018
1 parent 547f7b6 commit 5e1d22a
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 393 deletions.
1 change: 0 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function build() {
typescript({
target: 'ES5',
declaration: true,
module: 'umd',
})
)

Expand Down
23 changes: 12 additions & 11 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { ICacheStore } from 'jfetchs-util';
import { MemoryStore } from 'jfetchs-memory';
export { MemoryStore };
export interface ICacheOptions<T> {
/**
* 是否打印调试信息
*/
debug?: boolean | string;
/**
* 存储器
*/
store?: ICacheStore<T>;
/**
* 过期时间,单位:秒
*/
Expand All @@ -20,22 +27,14 @@ export interface ICacheOptions<T> {
* Cache of fetch data
* @author
* zswang (http://weibo.com/zswang)
* @version 0.1.15
* @date 2018-08-21
* @version 0.1.26
* @date 2018-09-12
*/
export declare class Cache<T> {
/**
* 配置项
*/
// private options;
/**
* 缓存开始时间
*/
// private fetchedAt;
/**
* 缓存数据
*/
// private fetchData;
/**
* 获取数据中
*/
Expand Down Expand Up @@ -206,6 +205,7 @@ export declare class Cache<T> {
// > cache6 3 error
})
cache6.flush(3)
cache6.flush()
cache6.fetch(6).then(data => {
console.log(data)
// > 666
Expand All @@ -215,6 +215,7 @@ export declare class Cache<T> {
```js
let error
const cache7 = new jfetchs.Cache({
store: new jfetchs.MemoryStore(),
fetch: () => {
if (error) {
return Promise.reject(error)
Expand Down Expand Up @@ -248,6 +249,6 @@ export declare class Cache<T> {
* 移除缓存 Remove cached data
* @param key 缓存标志,默认: ''
*/
flush(key?: string | number): void;
flush(key?: string | number): Promise<boolean>;
}
//# sourceMappingURL=index.d.ts.map
Loading

0 comments on commit 5e1d22a

Please sign in to comment.