xncbf / django-dynamodb-cache

Django cache backend for serverless
https://pypi.org/project/django-dynamodb-cache/
MIT License
31 stars 5 forks source link

Add clear method implementation #12

Closed esc5221 closed 1 year ago

esc5221 commented 1 year ago

Ref : https://gist.github.com/Swalloow/9966d576a9aafff482eef6b59c222baa

xncbf commented 1 year ago

Thanks for the first PR 😄 The reason I haven't implemented the clear method yet is because the cost of using scan is too high. As you knows, as the number of rows increases, the scan cost may increase.

I've been thinking about how to empty the entire row without using scan , but I haven't found one yet. Is there a better way?

esc5221 commented 1 year ago

Oh I see.. I didn't considered the high cost of scanning operation. But, isn't it better to have clear method implemented? Implementation may not be the best, but i think it is better than not having it at all. Users can use with their own risk.

Another option that i found was deleting the table and creating it again. But deleting the existing resource seems to be not quite right, so i choose to delete items without deleting the table. How do you think about this option?

xncbf commented 1 year ago

Dropping and recreating tables can take a long time also.

I agree with better than not having it at all. So, let me notify the user of the risk and leave it as a possibility for future improvement.

xncbf commented 1 year ago

Can you give an editing permission?

esc5221 commented 1 year ago
image

It's already enabled. Is there any other settings should i check?

xncbf commented 1 year ago

I don't know why pipelines failed All tests pass on my local env, so after merging we will change dynamodb for testing to sandbox.