<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def delete_pattern(self, pattern, count=None):
 """ delete cache according to pattern in redis, delete `count` keys each time """

        cursor = '0'
        count_deleted = 0
        while cursor != 0:
            cursor, identities = await self.client.scan(
                cursor=cursor, match=pattern, count=count
            )
            count_deleted += await self.client.delete(*identities)
        return count_deleted