Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature]: Allow TTL attribute to also be a partition or sort key #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MartinRamm
Copy link

Thank you for helping out! ✨

We really appreciate your commitment to improving Architect

To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following:

  • Forked the repo and created your branch from master
  • Made sure tests pass (run npm it from the repo root)
  • Expanded test coverage related to your changes:
    • Added and/or updated unit tests (if appropriate)
    • Added and/or updated integration tests (if appropriate)
  • Updated relevant documentation:
  • Summarized your changes in changelog.md
  • Linked to any related issues, PRs, etc. below that may relate to, consume, or necessitate these changes

Please also be sure to completed the CLA (if you haven't already).

Learn more about contributing to Architect here.

Thanks again!

MartinRamm added a commit to MartinRamm/arc.codes that referenced this pull request Dec 9, 2023
@ryanblock
Copy link
Member

Does DynamoDB actually support this? Why would one want to do this? It seems like kind of a bad idea for quite a few reasons.

@MartinRamm
Copy link
Author

Does DynamoDB actually support this? Why would one want to do this? It seems like kind of a bad idea for quite a few reasons.

I got no errors when adding TTL as a sort key on AWS. While I agree that it might be a bad idea to make TTL the primary key, I don't see why making it a sort key is a bad. Could you explain please?

@ryanblock
Copy link
Member

Getting no errors adding TTL as sort key doesn't mean it will actually work, but let's say for the sake of conversation that it does work. A few reasons that come to mind:

  • This does not generally abide by the principle of separation of concerns
  • TTL resolution is in seconds, not ms, so it's a pretty poor sort key
  • Keys cannot be mutated, so if you need to extend the TTL (say for a session or what have you), you must destroy the old item and create a new one
  • This behavior is, as far as I can tell, not documented; as such, I'm not confident it can be counted to work indefinitely. This could simply be a case that DynamoDB hasn't accounted for yet and they may disable it in the future – I'm just not sure!
  • As Architect is concerned, it's mixing metaphors (TTL is one thing, sort keys are another thing)

I'm still wondering what the necessity is here!

@ryanblock
Copy link
Member

@MartinRamm chatted some more about this internally and it was mentioned that maybe the goal here is to enable querying by something that will expire by a certain time? Was that the use case? Would love to hear more about what you're aiming to build with this functionality.

Anyway, I think we can get there with additions to documentation in https://github.com/architect/arc.codes

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants