Getting Started with Solidis
Learn how to integrate Solidis into your project and start building high-performance Redis applications.
Prerequisites
- Node.jsVersion 14.0 or higher (Node.js 22 LTS recommended)
- TypeScriptVersion 4.5 or higher (optional but recommended)
- RedisAny RESP-compatible server
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:
1// Import the basic client and commands
2import { SolidisClient } from '@vcms-io/solidis';
3import { get, set, multi } from '@vcms-io/solidis/command';
4import type { SolidisClientExtensions } from '@vcms-io/solidis';
5
6// Define extensions with type safety
7const extensions = {
8 get,
9 set,
10 multi,
11} satisfies SolidisClientExtensions;
12
13// Initialize client with extensions
14const client = new SolidisClient({
15 host: '127.0.0.1',
16 port: 6379,
17}).extend(extensions);2. Featured Client (SolidisFeaturedClient)
A convenience client with all RESP 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
Learn how to manage Redis connections
1// Create client (with lazy connect)
2const client = new SolidisClient({
3 uri: 'redis://127.0.0.1:6379',
4 lazyConnect: true,
5}).extend({ get, set });
6
7// Explicitly connect when needed
8await client.connect();
9
10// Handle connection events
11client.on('connect', () => console.log('Connected to server'));
12client.on('ready', () => console.log('Client is ready for commands'));
13client.on('error', (err) => console.error('Error occurred: ', err));
14client.on('close', () => console.log('Connection closed by server'));
15client.on('end', () => console.log('Connection closed'));
16
17// Close connection when done
18client.quit();Basic Operations
Common Redis operations with Solidis
1// Set a key
2await client.set('key', 'value');
3
4// Get a key
5const value = await client.get('key');
6
7console.log(value); // 'value'
8
9// Delete a key
10await client.del('key');Transactions
Working with Redis transactions
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
📚 API Reference
Explore the complete API documentation with detailed examples.
View API Reference →