UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'D9iA7Sz9ndoqIMhilzaOCkwbSjvNkKlPc4+VDf+/zuk=' 
WHERE 
  key_id = '1537de0304c4c5333982d46da1846f5a612420e4da070d8b0397c4c459dc8357' 
  AND (
    token = 'D9iA7Sz9ndoqIMhilzaOCkwbSjvNkKlPc4+VDf+/zuk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022