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

Query time 0.00048