Fix KeyvOptions

This commit is contained in:
Arylo
2018-03-19 15:29:01 +08:00
parent f32382e9fd
commit 47742853c9
2 changed files with 11 additions and 6 deletions
+6 -6
View File
@@ -10,9 +10,9 @@ interface KeyvOptions {
/** Namespace for the current instance. */
namespace?: string;
/** A custom serialization function. */
serialize: (data: any) => string;
serialize?: (data: any) => string;
/** A custom deserialization function. */
deserialize: (data: string) => any;
deserialize?: (data: string) => any;
/** The connection string URI. */
uri?: string;
/** The storage adapter instance to be used by Keyv. */
@@ -24,6 +24,10 @@ interface KeyvOptions {
}
declare class Keyv extends NodeJS.EventEmitter {
/**
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(opts?: KeyvOptions);
/**
* @param uri The connection string URI.
*
@@ -31,10 +35,6 @@ declare class Keyv extends NodeJS.EventEmitter {
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(uri?: string, opts?: KeyvOptions);
/**
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
*/
constructor(opts?: KeyvOptions);
/** Returns the value. */
get(key: string): Promise<any>;
/**
+5
View File
@@ -1,5 +1,10 @@
import Keyv = require("keyv");
new Keyv({
uri: 'redis://user:pass@localhost:6379',
namespace: "redis"
});
new Keyv('mongodb://user:pass@localhost:27017/dbname');
new Keyv('redis://user:pass@localhost:6379');
new Keyv('sqlite://path/to/database.sqlite');