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

typeorm / typeorm / 15219332477

23 May 2025 09:13PM UTC coverage: 17.216% (-59.1%) from 76.346%
15219332477

Pull #11332

github

naorpeled
cr comments - move if block
Pull Request #11332: feat: add new undefined and null behavior flags

1603 of 12759 branches covered (12.56%)

Branch coverage included in aggregate %.

0 of 31 new or added lines in 3 files covered. (0.0%)

14132 existing lines in 166 files now uncovered.

4731 of 24033 relevant lines covered (19.69%)

60.22 hits per line

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

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

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

UNCOV
15
    constructor(protected connection: DataSource) {}
×
16

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

21
    /**
22
     * Creates a new query result cache based on connection options.
23
     */
24
    create(): QueryResultCache {
UNCOV
25
        if (!this.connection.options.cache)
×
26
            throw new TypeORMError(
×
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

UNCOV
30
        const cache: any = this.connection.options.cache
×
31

UNCOV
32
        if (cache.provider && typeof cache.provider === "function") {
×
UNCOV
33
            return cache.provider(this.connection)
×
34
        }
35

UNCOV
36
        if (
×
37
            cache.type === "redis" ||
×
38
            cache.type === "ioredis" ||
39
            cache.type === "ioredis/cluster"
40
        ) {
41
            return new RedisQueryResultCache(this.connection, cache.type)
×
42
        } else {
UNCOV
43
            return new DbQueryResultCache(this.connection)
×
44
        }
45
    }
46
}
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

© 2025 Coveralls, Inc