UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qk8h13vtgfIunSzPecAUZMgUJ6ny4ax1x0ny3Pmx2qw=' 
WHERE 
  key_id = 'd8874cbceb765cdfdcdc62683afcfe826e8748aad918bdf236963de5134ef083' 
  AND (
    token = 'qk8h13vtgfIunSzPecAUZMgUJ6ny4ax1x0ny3Pmx2qw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037