UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'et95OusGYB9AEcGxDQoM2S8MnftceXTXtYEs+ccVaKU=' 
WHERE 
  key_id = '39a46b5a2765399b763978e1f85111468d96f2c312e4e4f986735836a76223fd' 
  AND (
    token = 'et95OusGYB9AEcGxDQoM2S8MnftceXTXtYEs+ccVaKU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00057