Skip to main content

GlobalCacheServer

Import the server from its dedicated entry point:

import { GlobalCacheServer } from '@global-cache/core/server';

Constructor

new GlobalCacheServer()

Creates an independent server instance.

Returns: A new GlobalCacheServer instance.

Methods

start

server.start(config?: GlobalCacheServerConfig): Promise<void>

Starts the server.

Parameters

NameTypeDescription
configGlobalCacheServerConfigOptional server configuration (see below).
PropertyTypeDescription
portnumberListening port. Uses an available port when omitted.
basePathstringPersistent storage directory. Defaults to .global-cache.

stop

server.stop(): Promise<void>

Stops a running server. Calling it when the server is already stopped is safe.

Properties

port

server.port: number

The resolved listening port, or 0 before the server starts.

localUrl

server.localUrl: string

The server URL using localhost and the resolved port.

isRunning

server.isRunning: boolean

Whether the server is accepting connections.