Skip to content

Migrate UserProfileService off in-memory storage #188

Description

@balisdev

Owner: whoever owns user-profile (unassigned) · Priority: Medium — does not block rollout of the Redis approach elsewhere.

Description

UserProfileService (src/user-profile/user-profile.service.ts) stores profiles in a Map<id, UserProfile> plus a Map<walletAddress, id> secondary index, both process-local. Follow-up from the persistence spike (#181) — see backend/PERSISTENT_STORAGE_SPIKE.md (§2) for the full write-up.

The one wrinkle: search() does a substring match across name, bio, and skills. Redis has no native equivalent at this data size without adding a separate search module (e.g. RediSearch), which isn't guaranteed available on every Redis deployment. Recommendation is to keep search() scanning findAll()'s results in-process after migration — same behavior as today, just backed by Redis instead of the Map — and only revisit proper search indexing if profile volume makes that too slow later.

Tasks

  • Migrate the profile store to Redis: entity as SET profile:{id} <json>, walletAddress -> id index as a Redis string (GET/SET), following the same pattern as GigService's prototype in Spike: Persistent, multi-instance-safe storage strategy to replace in-memory service state #181 — including its transaction-result verification, fallback metric, and production fail-fast behavior
  • Keep search() as an in-process scan over findAll() (no new search infra)
  • Add the same graceful-fallback-to-memory behavior on Redis errors, logged at error level, matching GigService/NonceStoreService
  • Update UserProfileController and any other callers for the resulting async signature changes (most methods are already async today, so this should be low-friction)

Acceptance Criteria

  • Profile state survives a process restart
  • Multiple backend instances observe the same profile state (including the wallet-address uniqueness check in create())
  • Existing user-profile.service.spec.ts / user-profile.controller.spec.ts tests still pass, updated for the new store

Estimated Time

1-2 days

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions