• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

typeorm / typeorm / 22256862981

21 Feb 2026 12:31PM UTC coverage: 81.291% (+0.1%) from 81.176%
22256862981

push

github

web-flow
feat!: remove deprecated `Connection` and `ConnectionOptions` (#12022)

27682 of 33521 branches covered (82.58%)

Branch coverage included in aggregate %.

1205 of 1301 new or added lines in 76 files covered. (92.62%)

1 existing line in 1 file now uncovered.

93920 of 116068 relevant lines covered (80.92%)

71235.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/cache/QueryResultCacheFactory.ts
1
import { RedisQueryResultCache } from "./RedisQueryResultCache"
26✔
2
import { DbQueryResultCache } from "./DbQueryResultCache"
26✔
3
import { QueryResultCache } from "./QueryResultCache"
26✔
4
import { DataSource } from "../data-source/DataSource"
26✔
5
import { TypeORMError } from "../error/TypeORMError"
26✔
6

26✔
7
/**
26✔
8
 * Caches query result into Redis database.
26✔
9
 */
26✔
10
export class QueryResultCacheFactory {
26✔
11
    // -------------------------------------------------------------------------
26✔
12
    // Constructor
26✔
13
    // -------------------------------------------------------------------------
26✔
14

26✔
15
    constructor(protected dataSource: DataSource) {}
26✔
16

26✔
17
    // -------------------------------------------------------------------------
26✔
18
    // Public Methods
26✔
19
    // -------------------------------------------------------------------------
26✔
20

26✔
21
    /**
26✔
22
     * Creates a new query result cache based on connection options.
26✔
23
     */
26✔
24
    create(): QueryResultCache {
26✔
25
        if (!this.dataSource.options.cache)
148✔
26
            throw new TypeORMError(
148!
27
                `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 }`,
×
28
            )
×
29

148✔
30
        const cache: any = this.dataSource.options.cache
148✔
31

148✔
32
        if (cache.provider && typeof cache.provider === "function") {
148✔
33
            return cache.provider(this.dataSource)
28✔
34
        }
28✔
35

120✔
36
        if (
120✔
37
            cache.type === "redis" ||
120✔
38
            cache.type === "ioredis" ||
148✔
39
            cache.type === "ioredis/cluster"
120✔
40
        ) {
148!
NEW
41
            return new RedisQueryResultCache(this.dataSource, cache.type)
×
42
        } else {
148✔
43
            return new DbQueryResultCache(this.dataSource)
120✔
44
        }
120✔
45
    }
148✔
46
}
26✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc