newCachedResolverResult wraps a ResolverResult such that it is cacheable. Unlike other ResolverResult implementations, it can be kept in memory for a long time and read multiple times. When used multiple times, call .copy() to get a copy with a reset iteration cursor.
(res ResolverResult)
| 402 | // Unlike other ResolverResult implementations, it can be kept in memory for a long time and read multiple times. |
| 403 | // When used multiple times, call .copy() to get a copy with a reset iteration cursor. |
| 404 | func newCachedResolverResult(res ResolverResult) (*cachedResolverResult, error) { |
| 405 | data, err := res.MarshalJSON() |
| 406 | if err != nil { |
| 407 | return nil, err |
| 408 | } |
| 409 | |
| 410 | return &cachedResolverResult{ |
| 411 | data: data, |
| 412 | meta: res.Meta(), |
| 413 | schema: res.Schema(), |
| 414 | }, nil |
| 415 | } |
| 416 | |
| 417 | type cachedResolverResult struct { |
| 418 | data []byte |
no test coverage detected