• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zincware / ZnSocket / 20220197954

12 Dec 2025 06:36AM UTC coverage: 71.788% (+6.8%) from 64.954%
20220197954

push

github

web-flow
Feature/improve-memory-storage (#116)

* introduce memory storage

* rename storage class

* Add Redis-compatible sorted sets, expiry, and scan to MemoryStorage

Implements missing Redis operations needed for zndraw application:

- Sorted set operations: zadd, zcard, zrange, zrangebyscore,
  zrevrangebyscore, zrem, zcount with O(log n) performance using
  sortedcontainers.SortedList
- Expiry/TTL support: setex, expire with lazy cleanup on access
- Key scanning: scan_iter with glob pattern matching
- Enhanced thread safety with expiry checks on all read operations
- Pipeline support matching redis-py behavior

All 80 tests pass against both MemoryStorage and Redis to ensure
exact API compatibility. MemoryStorage now serves as a drop-in
replacement for Redis in single-process scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Enhance MemoryStorage with full Redis-py API compatibility

Add comprehensive Redis-compatible features to MemoryStorage to ensure
exact API parity with redis-py for improved testing and development.

Key enhancements:
- Add nx, xx, ex parameters to set() method for conditional sets and expiration
- Implement incr() and decr() methods for atomic counter operations
- Add count parameter to scan_iter() for result limiting
- Fix hgetall() to return independent copies instead of internal references
- Add _encode_value() method with strict type validation matching Redis

Type validation now exactly matches Redis behavior:
- Accept: str, bytes, int, float (converting numbers to strings)
- Reject: bool, dict, list, and other types with DataError

Test coverage:
- 131 total tests (previously 88)
- All tests pass for both MemoryStorage and redisclient
- Added tests for JSON string handling, type validation, and edge cases
- Verified exact behavioral compatibility with Redis

This ensures MemoryStorage can be used as a drop-in replacement for
Redis during testing with... (continued)

470 of 604 new or added lines in 4 files covered. (77.81%)

1 existing line in 1 file now uncovered.

1397 of 1946 relevant lines covered (71.79%)

2.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.15
/znsocket/objects/list_obj.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc