MCPcopy
hub / github.com/redis/node-redis / create

Method create

packages/client/lib/client/pool.ts:168–201  ·  view source on GitHub ↗
(
    clientOptions?: Omit<RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>, "clientSideCache">,
    options?: Partial<RedisPoolOptions>
  )

Source from the content-addressed store, hash-verified

166 static #SingleEntryCache = new SingleEntryCache<any, any>();
167
168 static create<
169 M extends RedisModules,
170 F extends RedisFunctions,
171 S extends RedisScripts,
172 RESP extends RespVersions,
173 TYPE_MAPPING extends TypeMapping = {}
174 >(
175 clientOptions?: Omit<RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>, "clientSideCache">,
176 options?: Partial<RedisPoolOptions>
177 ) {
178
179 let Pool = RedisClientPool.#SingleEntryCache.get(clientOptions);
180 if(!Pool) {
181 Pool = attachConfig({
182 BaseClass: RedisClientPool,
183 commands: NON_STICKY_COMMANDS,
184 createCommand: RedisClientPool.#createCommand,
185 createModuleCommand: RedisClientPool.#createModuleCommand,
186 createFunctionCommand: RedisClientPool.#createFunctionCommand,
187 createScriptCommand: RedisClientPool.#createScriptCommand,
188 config: clientOptions
189 });
190 Pool.prototype.Multi = RedisClientMultiCommand.extend(clientOptions);
191 RedisClientPool.#SingleEntryCache.set(clientOptions, Pool);
192 }
193
194 // returning a "proxy" to prevent the namespaces._self to leak between "proxies"
195 return Object.create(
196 new Pool(
197 clientOptions,
198 options
199 )
200 ) as RedisClientPoolType<M, F, S, RESP, TYPE_MAPPING>;
201 }
202
203 // TODO: defaults
204 static #DEFAULTS = {

Callers 2

withCommandOptionsMethod · 0.45
_commandOptionsProxyMethod · 0.45

Calls 4

attachConfigFunction · 0.90
getMethod · 0.45
extendMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected