MindexDB Demo
About MindexDB
MindexDB is a lightweight, Redis-like wrapper for IndexedDB, providing a simple and intuitive API for working with client-side storage in web applications.
Features
- Simple Redis-like API
- Support for key-value, hash, and list operations
- Key expiration using Web Workers
- Promise-based interface
- TypeScript-friendly with JSDoc comments
Usage Example
// Create a new instance of MindexDB
const db = new MindexDB('myDatabase');
// Connect to the database
await db.connect();
// Set a key-value pair
await db.set('user:1', 'John Doe');
// Get a value
const user = await db.get('user:1');
console.log(user); // Output: John Doe
// Set a hash field
await db.hset('user:2', 'name', 'Jane Doe');
// Get a hash field
const name = await db.hget('user:2', 'name');
console.log(name); // Output: Jane Doe
// Push items to a list
await db.rpush('mylist', 'item1', 'item2', 'item3');
// Get items from a list
const items = await db.lrange('mylist', 0, -1);
console.log(items); // Output: ['item1', 'item2', 'item3']
// Set expiration on a key
await db.expire('user:1', 60); // Expires in 60 seconds
Interactive Demo
Browser Compatibility
MindexDB works in all modern browsers that support IndexedDB and Web Workers:
- Chrome 24+
- Firefox 16+
- Safari 10+
- Edge 12+
- Opera 15+