# TTL Index Implementation Note

## Task 2.6: Create TTL index for OAuth sessions

The TTL index must be created in the plugin's `init` method (Task Group 5).

### Implementation Details:

```typescript
// In OAuthPlugin.init() method:
await db.collection('oauth_sessions').createIndex(
    { createdAt: 1 },
    { expireAfterSeconds: 600 }  // 10 minutes
);
```

### Purpose:
- Automatically removes expired OAuth sessions after 10 minutes
- Prevents session table bloat
- MongoDB handles cleanup automatically via TTL monitor

### Configuration:
- Default TTL: 600 seconds (10 minutes)
- Should be configurable via `sessionTTL` option in plugin config
- Index field: `createdAt`
- Collection: `oauth_sessions`

This note should be referenced when implementing Task Group 5 (OAuthPlugin class).
