Getting Started with Solidis
Learn how to integrate Solidis into your project and start building high-performance Redis applications.
Prerequisites
- Node.jsVersion 18.0 or higher (Node.js 22 LTS recommended)
- TypeScriptOptional; set moduleResolution to node16, nodenext or bundler so the subpath imports resolve
- RedisRedis 6.2 or later, or Valkey 7.2 or later
Installation
Install Solidis using your preferred package manager
npm install @vcms-io/solidisClient Types
Choose the right client for your needs
1. Basic Client (SolidisClient)
The basic client contains minimal functionality to reduce bundle size. You need to extend it with specific commands:
1import { SolidisClient } from '@vcms-io/solidis';
2import { del, get, incr, multi, set } from '@vcms-io/solidis/command';
3
4const extensions = {
5 get,
6 set,
7 del,
8 incr,
9 multi,
10};
11
12const client = new SolidisClient({
13 host: '127.0.0.1',
14 port: 6379,
15}).extend(extensions);2. Featured Client (SolidisFeaturedClient)
A convenience client with all 384 built-in commands pre-loaded:
1import { SolidisFeaturedClient } from '@vcms-io/solidis/featured';
2
3const client = new SolidisFeaturedClient({
4 host: '127.0.0.1',
5 port: 6379,
6});Connection Management
With lazyConnect, connect() opens the connection; events report its state
1const client = new SolidisClient({
2 uri: 'redis://127.0.0.1:6379',
3 lazyConnect: true,
4}).extend({ get, set, del, incr, multi });
5
6client.on('connect', () => console.log('Connected to server'));
7client.on('ready', () => console.log('Client is ready for commands'));
8client.on('error', (err) => console.error('Error occurred: ', err));
9client.on('end', () => console.log('Client quit'));
10
11await client.connect();
12
13client.quit();Basic Operations
Each command returns a promise of its reply
1await client.set('key', 'value');
2
3const value = await client.get('key');
4console.log(value); // 'value'
5
6await client.del('key');Transactions
multi() queues commands and exec() runs them atomically
1const transaction = client.multi();
2
3transaction.set('key', 'value');
4transaction.incr('counter');
5transaction.get('key');
6
7const results = await transaction.exec();Next Steps
Continue your journey with Solidis
