UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HeQ2Pa5DBqn02KLFp3zJ0XAvwpI55pkwSfRDIPwhMSs=' 
WHERE 
  key_id = '8fa4714b72729fec2d992c86bf5399cc30e653c781fc012e880bbcdb0e37c9ce' 
  AND (
    token = 'HeQ2Pa5DBqn02KLFp3zJ0XAvwpI55pkwSfRDIPwhMSs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029