UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NhrgYXpI9Iomzq7zJ0s1tPUTbFeTSuL+OJi6vmwub2I=' 
WHERE 
  key_id = '046da227286921e690039639a8de66de6420c6896038910d672329de7ddc7437' 
  AND (
    token = 'NhrgYXpI9Iomzq7zJ0s1tPUTbFeTSuL+OJi6vmwub2I=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032