UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '1vgT6S+G7cO582x0TdtT4CX2w3XHN1F8PEkOVz0hFp8=' 
WHERE 
  key_id = '8464dee6f04b91f82be9f0840c340c5232f00db42d9a1e472277e2872a236d67' 
  AND (
    token = '1vgT6S+G7cO582x0TdtT4CX2w3XHN1F8PEkOVz0hFp8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034