UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '20kMcQuHdQL+PCU3Sma9P39CC741ZXhecEE8na/9YCA=' 
WHERE 
  key_id = '0df317215e4c54e9fb36e46d037c7e2c5de2b40886a12502c996edd077d47c6b' 
  AND (
    token = '20kMcQuHdQL+PCU3Sma9P39CC741ZXhecEE8na/9YCA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032