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

Query time 0.00026