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

typeorm / typeorm / 19549987525

20 Nov 2025 08:11PM UTC coverage: 80.769% (+4.3%) from 76.433%
19549987525

push

github

web-flow
ci: run tests on commits to master and next (#11783)

Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>

26500 of 32174 branches covered (82.36%)

Branch coverage included in aggregate %.

91252 of 113615 relevant lines covered (80.32%)

88980.79 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 connection: 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.connection.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.connection.options.cache
148✔
31

148✔
32
        if (cache.provider && typeof cache.provider === "function") {
148✔
33
            return cache.provider(this.connection)
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!
41
            return new RedisQueryResultCache(this.connection, cache.type)
×
42
        } else {
148✔
43
            return new DbQueryResultCache(this.connection)
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