Skip to content

Add configurable chain separator (Issue #52 - 1/2) - #104

Open
rsnk96 wants to merge 2 commits into
Attumm:v3.3.0-pre-releasefrom
detecttechnologies:feat/configurable-separator
Open

rsnk96 wants to merge 2 commits into
Attumm:v3.3.0-pre-releasefrom
detecttechnologies:feat/configurable-separator

Conversation

@rsnk96

@rsnk96 rsnk96 commented Mar 25, 2026 •

Copy link
Copy Markdown

This PR adds a configurable chain separator to RedisDict (resolves #52). Previously, the chain separator was hardcoded to :, which could cause key collisions when user keys contained colons. The separator is now configurable via a constructor parameter and defaults to ➡️ (emoji + spaces) to avoid collisions in typical use cases.

Test code:

from redis_dict import RedisDict

# Create RedisDict with custom separator
r = RedisDict(namespace='test')
r.clear()

# Use chain operations
r.chain_set(['foo', 'bar'], 'value1')
r.chain_set(['foo', 'bar2'], 'value2')

# No collision with user keys containing ':'
r['foo:bar'] = 'direct_value'

print("Normal chain get of foo, bar: ", r.chain_get(['foo', 'bar']))
print("Specific key explicitly set:  ", r['foo:bar'])
print("Multi chain get of foo:       ", r.multi_chain_get(['foo']))
print("List of all keys:             ", list(r._scan_keys("*")))

Behaviour before this PR:

Normal chain get of foo, bar:  direct_value
Specific key explicitly set:   direct_value
Multi chain get of foo:        ['value2', 'direct_value']
List of all keys:              ['test:foo:bar2', 'test:foo:bar']

Behaviour after this PR:

Normal chain get of foo, bar:  value1
Specific key explicitly set:   direct_value
Multi chain get of foo:        ['value1', 'direct_value', 'value2']
List of all keys:              ['test:foo➡️     bar', 'test:foo:bar', 'test:foo➡️     bar2']

@rsnk96 rsnk96 changed the title Add configurable chain separator (Issue #52) Add configurable chain separator (Issue #52 - 1/2) Mar 25, 2026
@rsnk96
rsnk96 marked this pull request as ready for review March 25, 2026 22:17
- Add `separator` parameter to RedisDict (defaults to '➡️    ')
- Update chain_set/get/del and multi_chain_get/multi_dict to use it
- Add tests for configurable separator
- Fix E302 pylama lint error (missing blank line before class)
- Document `bash scripts/tests.sh` for contributors in README

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rsnk96
rsnk96 force-pushed the feat/configurable-separator branch from 27f0a62 to a72224d Compare March 26, 2026 00:00
@Attumm
Attumm changed the base branch from main to v3.3.0-pre-release April 12, 2026 12:04
@Attumm
Attumm self-requested a review April 12, 2026 12:04
Comment thread src/redis_dict/core.py
Comment thread src/redis_dict/core.py
Comment thread src/redis_dict/core.py
Comment thread README.md
Comment thread pyproject.toml

[tool.mypy]
python_version = "3.8"
python_version = "3.9"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a reason for 3.8 and not higher. Can't remember why exactly. Hmm

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I'm guessing you mean the failing pylama. Well, we'll get that fixed now!

rsnk96 pushed a commit to detecttechnologies/redis-dict that referenced this pull request Apr 12, 2026
Address upstream review comments on PR Attumm#104:
- Rename _DEFAULT_SEPARATOR → _DEFAULT_CHAIN_SEPARATOR to clarify purpose
- Rename separator param/attr → chain_separator throughout
- Revert default value from emoji to ':' for backwards compatibility
- Add TODO comment to revisit default in a future major release
- Revert mypy python_version back to 3.8

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rsnk96 pushed a commit to detecttechnologies/redis-dict that referenced this pull request Apr 12, 2026
Address upstream review comments on PR Attumm#104:
- Rename _DEFAULT_SEPARATOR → _DEFAULT_CHAIN_SEPARATOR to clarify purpose
- Rename separator param/attr → chain_separator throughout
- Revert default value from emoji to ':' for backwards compatibility
- Add TODO comment to revisit default in a future major release

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Improving consistency in usage of redis-dict

2 participants