UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'PAVkJpCVCQdn2OTQpK8z/0Ce5hztxatXt8rm5iT379A=' 
WHERE 
  key_id = '8e95c1052229041df2541d82188252aa167bf966fe9ce20e375838e64ec28f15' 
  AND (
    token = 'PAVkJpCVCQdn2OTQpK8z/0Ce5hztxatXt8rm5iT379A=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029