UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'IvKRJ5bM1JswBA5CD11AnL6UXQ1YmDgiuzzUSRq038Y=' 
WHERE 
  key_id = '8694ba50da38ad20b5b0760428f2822c97bf2e773bd5f8e2066e889aa670c4e3' 
  AND (
    token = 'IvKRJ5bM1JswBA5CD11AnL6UXQ1YmDgiuzzUSRq038Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032