Junior — Senior
In-memory user profile cache with TTL (Time To Live) limit
livecode
Task condition
It is necessary to develop an in-memory cache that:
- Returns a user's profile and related orders by their unique identifier (UUID).
- Stores data only for a specified period — after the TTL expires, the record is automatically deleted.
- Allows operations on orders: adding a new one, updating an existing one, and deleting.
- Contains a set of tests illustrating typical cache usage.
package main
import (
"log"
"time"
)
type UserProfile struct {
UUID string
Name string
Orders []Order
}
type Order struct {
UUID string
CreatedAt time.Time
UpdatedAt time.Time
Basket interface{}
}
func main() {
x := 2 + 2
if x != 4 {
log.Fatalf("expected 4, got %d", x)
}
log.Println("Tests passed")
}