1.0.13 • Published 4 years ago

cache-localstorage v1.0.13

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

使用说明

(0)支持的方法

```
import LocalCache from 'cache-localstorage';
//setItem
LocaCache.set('tom','cat',3);
//getItem
LocaCache.get('tom');//return a json type
//expired or not
LocaCache.expired('tom');//return a boolean ,ture <=> expired ,false <=> not expired
//removeItem
LocalCache.remove('tom');
//return a boolen,true <=> has removed, false <=> not removed
//clear all
LocalCache.clear();
```

(1)how to use ?

Attention :

if you want to cache more datas ,you should use the key of "other" ,

and the key of "key"&"value"&"time"&"other" is unique ,you should according to rules ;

存储对象的key和value是名称和值,time是存储的时间,other是要存储的其他对象;这些关键字是固定的,不能改变;

A error set

eg:

```
    let a = {mykey : 'tom' ,myvalue : 'cat' ,mytime : 3, myother:{}};
    LocalCache.set(a);//存储a
    //this is an error set , you should not use key of "mykey"&"myvalue"&"mytime&myother" ;
    //must use key of " key, value, time ,other";
```

A correct set

```
    let a = {key : 'tom' ,value : 'cat' ,time : 3, other:{}};
    LocalCache.set(a);//存储a
```
1.setItem params is an object 存储,传入一个对象
eg:
    ```
    import LocalCache from 'cache-localstorage';
    let a = {key : 'tom' ,value : 'cat' ,time : 3, other:{}};
    LocalCache.set(a);//存储a
    ```
2.setItem params is array
存储,传入一个数组对象
```
import LocalCache from 'cache-localstorage';
let a = [{key:'tom',value:'cat'},{key : 'jack',value:'man'}];
LocalCache.set(a);//存储a
```
3.setItem , parms is string;
必传参数(key,value),选传参数(time, other);
    ```
    import LocalCache from 'cache-localstorage';
    LocalCache.set('tom' ,'cat');//存储a
    LocalCache.set('tom','cat',3);//默认存储时间为一天
    LocalCache.set('tom','cat','sss');//第三个参数不为number则认为传的是第四个参数,time默认为一天
    LocalCache.set('tom','cat',2,'sss');//四个参数全部传的形态
    ```
1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago