UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O8SB0ckv+YgxynT7T2I0MbWlsz3n+dNysFPA8vk+ODM=' 
WHERE 
  key_id = '5d50dda42153721bb71f4f4bc437abe266dd0fcc121fa9bb6b90987f6dc31397' 
  AND (
    token = 'O8SB0ckv+YgxynT7T2I0MbWlsz3n+dNysFPA8vk+ODM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00020