How to delete from Redis List faster then o(n)

922 views Asked by At

Is there a way to delete all objects in a redis list faster then o(n) ? like the way truncate works in DB, just point the first object to null or something..

1

There are 1 answers

2
for_stack On BEST ANSWER

NO. There's no way to make the delete operation faster than O(n), since Redis has to free resources for each item one-by-one.

However, with the UNLINK command, you can ask Redis to delete the list asynchronously, so that the delete operation won't block Redis, but delete the list in a background thread. Check this question for more info.