Skip to content

Add TTL management and atomic counters to cache service - #67

Merged
NitinKumar004 merged 1 commit into
developmentfrom
feature/cache-ttl-increment
Mar 31, 2026
Merged

Add TTL management and atomic counters to cache service#67
NitinKumar004 merged 1 commit into
developmentfrom
feature/cache-ttl-increment

Conversation

@NitinKumar004

Copy link
Copy Markdown
Collaborator

Summary

  • Adds 7 new methods to cache driver interface: Expire, GetTTL, Persist, Incr, IncrBy, Decr, DecrBy
  • Implements across all 3 providers: AWS ElastiCache, Azure Cache for Redis, GCP Memorystore
  • Wires through portable API layer with metrics, recording, rate limiting, and error injection
  • Incr/Decr on non-existent keys start from 0 (Redis behavior)
  • Incr/Decr preserve existing TTL on the key
  • GetTTL returns -1 for keys with no TTL (Redis behavior)
  • Emits provider-native metrics for counter operations

Closes #64

Test plan

Unit tests (per provider - 8-12 tests each)

  • TestExpire — set TTL on existing key, verify via GetTTL, verify expiry
  • TestExpireKeyNotFound — returns error for missing key
  • TestPersist — remove TTL, verify key survives past original expiry
  • TestPersistKeyNotFound — returns error for missing key
  • TestIncr — increment from 0, increment again
  • TestIncrBy — increment by arbitrary delta
  • TestDecr — decrement existing value
  • TestDecrBy — decrement by arbitrary delta
  • TestIncrNonInteger — returns error for non-integer values
  • TestIncrPreservesTTL — TTL preserved after increment
  • TestIncrCacheNotFound — returns error for missing cache (AWS)

Integration tests (cloudemu_test.go)

  • TestCacheExpireAndPersistAWS / Azure / GCP
  • TestCacheIncrDecrAWS / Azure / GCP

Verification

  • Linter: 0 issues (golangci-lint run --timeout=9m ./...)
  • Full test suite: all passing (go test ./...)

@NitinKumar004
NitinKumar004 merged commit 73476d9 into development Mar 31, 2026
@NitinKumar004 NitinKumar004 mentioned this pull request Mar 31, 2026
@NitinKumar004
NitinKumar004 deleted the feature/cache-ttl-increment branch April 30, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TTL/Expiration, Increment/Decrement, and Pub/Sub to Cache service

1 participant