How genc-murat/crystalcache works
Main Components
a) Client Interface Layer:
• RESP (Redis Serialization Protocol) handler (/pkg/resp)
• Connection management and client handlers (/internal/client)
• ACL management system (/internal/core/acl)
b) Command Processing Layer:
• Command router (/internal/handlers)
• Handler registry system
• Pipeline and transaction management
c) Core Storage Layer:
• Memory cache implementation (/internal/cache)
• Data structure implementations:
• Basic types (Strings, Lists, Sets, Hashes)
• Advanced types (Bitmap, BloomFilter, HyperLogLog, etc.)
• Specialized structures (GeoSpatial, TimesSeries)
d) Persistence Layer:
• AOF (Append-Only File) system (/internal/storage)
• Recovery management
e) Supporting Systems:
• Connection pooling (/internal/pool)
• Metrics collection (/internal/metrics)
• Configuration management (/config)
Component Relationships
[Client] → [RESP Protocol Handler] → [ACL Layer] → [Command Router] →
[Handler Registry] → [Core Cache Layer] → [Data Structures]
• ↓
• [Persistence Layer]
Specific Implementation Details
a) Following interfaces:
/internal/core/ports/
• cache.go
• pool.go
• server.go
• storage.go
b) Data structure implementations:
/internal/cache/
• memory.go
• memory_bitmap.go
• memory_bloomfilter.go
• [other specialized implementations]
Key Architectural Patterns to Emphasize
• Hexagonal Architecture (ports and adapters pattern)
• Command Pattern (in handlers)
• Factory Pattern (pool factory)
• Repository Pattern (storage implementation)
Additional Elements
a) External Interfaces:
• Metrics endpoint (port 2112)
• Main server port (6379)
• Replication connections
b) Cross-Cutting Concerns:
• Metrics collection
• Configuration management
• Error handling
• Retry mechanisms
Create distinct sections for:
Special Notes
• Bidirectional flows where applicable
• Async operations (like AOF writing)
• Replication paths
• Transaction boundaries
• Connection pooling mechanism
Scale and Detail Level
• Keep high-level architecture visible at a glance
• Provide zoom-in sections for complex subsystems