1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var RedisQueryResultCache_1 = require("./RedisQueryResultCache");
|
4 | var DbQueryResultCache_1 = require("./DbQueryResultCache");
|
5 |
|
6 |
|
7 |
|
8 | var QueryResultCacheFactory = (function () {
|
9 |
|
10 |
|
11 |
|
12 | function QueryResultCacheFactory(connection) {
|
13 | this.connection = connection;
|
14 | }
|
15 |
|
16 |
|
17 |
|
18 | |
19 |
|
20 |
|
21 | QueryResultCacheFactory.prototype.create = function () {
|
22 | if (!this.connection.options.cache)
|
23 | throw new Error("To use cache you need to enable it in connection options by setting cache: true or providing some caching options. Example: { host: ..., username: ..., cache: true }");
|
24 | if (this.connection.options.cache.type === "redis")
|
25 | return new RedisQueryResultCache_1.RedisQueryResultCache(this.connection, "redis");
|
26 | if (this.connection.options.cache.type === "ioredis")
|
27 | return new RedisQueryResultCache_1.RedisQueryResultCache(this.connection, "ioredis");
|
28 | if (this.connection.options.cache.type === "ioredis/cluster")
|
29 | return new RedisQueryResultCache_1.RedisQueryResultCache(this.connection, "ioredis/cluster");
|
30 | return new DbQueryResultCache_1.DbQueryResultCache(this.connection);
|
31 | };
|
32 | return QueryResultCacheFactory;
|
33 | }());
|
34 | exports.QueryResultCacheFactory = QueryResultCacheFactory;
|
35 |
|
36 |
|