UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P61T4M4UzxoWWQUMrEQRVG9euimAOpfZaFyhbbA0Das=' 
WHERE 
  key_id = '9747ee1f503d1aa9cc0cfab81a7cd0de347e7cf9a2d3d1189d337d89a387d0ac' 
  AND (
    token = 'P61T4M4UzxoWWQUMrEQRVG9euimAOpfZaFyhbbA0Das=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027