Skip to content

feat: add caching infrastructure for Drive metadata #84

@rianjs

Description

@rianjs

Summary

Add a caching layer to support fast repeated lookups for Drive API metadata. This is Phase 1 of shared drive support (Phase 2: #85).

Motivation

When using --drive <name> flags (Phase 2), the CLI needs to resolve drive names to IDs. Without caching, every command would require an API call to list shared drives. Caching enables fast repeated lookups.

Implementation

Cache Package (internal/cache/)

  • TTL-based cache with configurable expiration
  • GetDrives() / SetDrives() for shared drive lists
  • Clear() to remove all cached data
  • GetStatus() for status reporting
  • Cache stored in ~/.config/google-readonly/cache/

Config Updates (internal/config/)

  • Config struct for user settings
  • LoadConfig() / SaveConfig() for persistence
  • Default 24-hour cache TTL

New Commands

gro config cache show      # Display cache status
gro config cache clear     # Clear all cached data
gro config cache ttl <N>   # Set cache TTL to N hours

Init Integration

  • Add cache TTL prompt during gro init setup

Files to Create/Modify

  • internal/cache/cache.go - NEW
  • internal/cache/cache_test.go - NEW
  • internal/cmd/config/cache.go - NEW
  • internal/config/config.go - Add Config struct
  • internal/cmd/config/config.go - Register cache subcommand
  • internal/cmd/initcmd/init.go - Add cache TTL prompt
  • README.md - Document cache configuration

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