UNPKG

2.65 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/cache/QueryResultCacheFactory.ts"],"names":[],"mappings":";;AAAA,iEAA8D;AAC9D,2DAAwD;AAIxD;;GAEG;AACH;IAEI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,iCAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAC5C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,wCAAM,GAAN;QACI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK;YAC9B,MAAM,IAAI,KAAK,CAAC,uKAAuK,CAAC,CAAC;QAE7L,IAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAa,CAAC,IAAI,KAAK,OAAO;YACvD,OAAO,IAAI,6CAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAE/D,IAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAa,CAAC,IAAI,KAAK,SAAS;YACzD,OAAO,IAAI,6CAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAEjE,IAAK,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAa,CAAC,IAAI,KAAK,iBAAiB;YACjE,OAAO,IAAI,6CAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;QAEzE,OAAO,IAAI,uCAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAEL,8BAAC;AAAD,CAhCA,AAgCC,IAAA;AAhCY,0DAAuB","file":"QueryResultCacheFactory.js","sourcesContent":["import {RedisQueryResultCache} from \"./RedisQueryResultCache\";\nimport {DbQueryResultCache} from \"./DbQueryResultCache\";\nimport {QueryResultCache} from \"./QueryResultCache\";\nimport {Connection} from \"../connection/Connection\";\n\n/**\n * Caches query result into Redis database.\n */\nexport class QueryResultCacheFactory {\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected connection: Connection) {\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query result cache based on connection options.\n */\n create(): QueryResultCache {\n if (!this.connection.options.cache)\n 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 }`);\n\n if ((this.connection.options.cache as any).type === \"redis\")\n return new RedisQueryResultCache(this.connection, \"redis\");\n\n if ((this.connection.options.cache as any).type === \"ioredis\")\n return new RedisQueryResultCache(this.connection, \"ioredis\");\n\n if ((this.connection.options.cache as any).type === \"ioredis/cluster\")\n return new RedisQueryResultCache(this.connection, \"ioredis/cluster\");\n\n return new DbQueryResultCache(this.connection);\n }\n\n}\n"],"sourceRoot":".."}
\No newline at end of file