UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QHgROQnFmXm9l5pwRhUwW0UJ0PpIjm0qRMVS+MrEtZg=' 
WHERE 
  key_id = '2fd5f3ad12369ca933782e8d5025f6b92fa8e5366df82b18cc5787d27aed6347' 
  AND (
    token = 'QHgROQnFmXm9l5pwRhUwW0UJ0PpIjm0qRMVS+MrEtZg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039