UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'MtS4BGCXTeVTMFHiIKef58NojEcNnEyfsrnUo60Ps84=' 
WHERE 
  key_id = '0f3fe90076b9ea45618718f2de979e081842c66ea792f7a202f5137f483626a2' 
  AND (
    token = 'MtS4BGCXTeVTMFHiIKef58NojEcNnEyfsrnUo60Ps84=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035