Search code examples
redisredis-cluster

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


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


Solution

  • 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.