UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ZGm1GgT7TG2Y0JdECtcCtvz8qdSRzYBxq7rt9GCK6WY=' 
WHERE 
  key_id = '9385c1049d387fa8f0a8f5c9e38217863f48ca465cf035dcdc16435971b59672' 
  AND (
    token = 'ZGm1GgT7TG2Y0JdECtcCtvz8qdSRzYBxq7rt9GCK6WY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032